You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/05/15 23:13:43 UTC
[1/2] git commit: Fixed mesos to pipe all close()s through
os::close().
Updated Branches:
refs/heads/master 8ecb6edde -> a615c5824
Fixed mesos to pipe all close()s through os::close().
Review: https://reviews.apache.org/r/11185
Project: http://git-wip-us.apache.org/repos/asf/incubator-mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mesos/commit/a615c582
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mesos/tree/a615c582
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mesos/diff/a615c582
Branch: refs/heads/master
Commit: a615c582483179da499b247c32230b8452710f39
Parents: dcdc88b
Author: Vinod Kone <vi...@twitter.com>
Authored: Wed May 15 14:08:29 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Wed May 15 14:13:26 2013 -0700
----------------------------------------------------------------------
src/launcher/executor.cpp | 8 ++++----
src/slave/process_isolator.cpp | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/a615c582/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 58ec848..1a6725a 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -158,7 +158,7 @@ public:
if (pid == 0) {
// In child process, we make cleanup easier by putting process
// into it's own session.
- close(pipes[0]);
+ os::close(pipes[0]);
// NOTE: We setsid() in a loop because setsid() might fail if another
// process has the same process group id as the calling process.
@@ -184,7 +184,7 @@ public:
abort();
}
- close(pipes[1]);
+ os::close(pipes[1]);
// The child has successfully setsid, now run the command.
std::cout << "sh -c '" << task.command().value() << "'" << std::endl;
@@ -195,7 +195,7 @@ public:
}
// In parent process.
- close(pipes[1]);
+ os::close(pipes[1]);
// Get the child's pid via the pipe.
if (read(pipes[0], &pid, sizeof(pid)) == -1) {
@@ -204,7 +204,7 @@ public:
abort();
}
- close(pipes[0]);
+ os::close(pipes[0]);
std::cout << "Forked command at " << pid << std::endl;
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/a615c582/src/slave/process_isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/process_isolator.cpp b/src/slave/process_isolator.cpp
index 11a5d18..2224d62 100644
--- a/src/slave/process_isolator.cpp
+++ b/src/slave/process_isolator.cpp
@@ -169,14 +169,14 @@ void ProcessIsolator::launchExecutor(
}
if (pid > 0) {
- close(pipes[1]);
+ os::close(pipes[1]);
// Get the child's pid via the pipe.
if (read(pipes[0], &pid, sizeof(pid)) == -1) {
PLOG(FATAL) << "Failed to get child PID from pipe";
}
- close(pipes[0]);
+ os::close(pipes[0]);
// In parent process.
LOG(INFO) << "Forked executor at " << pid;
@@ -189,7 +189,7 @@ void ProcessIsolator::launchExecutor(
} else {
// In child process, we make cleanup easier by putting process
// into it's own session. DO NOT USE GLOG!
- close(pipes[0]);
+ os::close(pipes[0]);
// NOTE: We setsid() in a loop because setsid() might fail if another
// process has the same process group id as the calling process.
@@ -216,7 +216,7 @@ void ProcessIsolator::launchExecutor(
abort();
}
- close(pipes[1]);
+ os::close(pipes[1]);
// Setup the environment for launcher.
foreachpair (const string& key, const string& value, env) {
[2/2] git commit: Fixed libprocess to pipe all close()s through
os::close().
Posted by vi...@apache.org.
Fixed libprocess to pipe all close()s through os::close().
Review: https://reviews.apache.org/r/11184
Project: http://git-wip-us.apache.org/repos/asf/incubator-mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mesos/commit/dcdc88b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mesos/tree/dcdc88b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mesos/diff/dcdc88b2
Branch: refs/heads/master
Commit: dcdc88b272589ab51e82e1a285059d1302325c05
Parents: 8ecb6ed
Author: Vinod Kone <vi...@twitter.com>
Authored: Wed May 15 11:51:45 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Wed May 15 14:13:26 2013 -0700
----------------------------------------------------------------------
third_party/libprocess/include/process/socket.hpp | 11 +++++++++--
third_party/libprocess/src/encoder.hpp | 4 ++--
third_party/libprocess/src/httpd.cpp | 6 ++++--
third_party/libprocess/src/net.hpp | 4 +++-
third_party/libprocess/src/process.cpp | 12 ++++++------
5 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/dcdc88b2/third_party/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/include/process/socket.hpp b/third_party/libprocess/include/process/socket.hpp
index f466963..669a333 100644
--- a/third_party/libprocess/include/process/socket.hpp
+++ b/third_party/libprocess/include/process/socket.hpp
@@ -4,6 +4,12 @@
#include <assert.h>
#include <unistd.h> // For close.
+#include <iostream>
+
+#include <stout/nothing.hpp>
+#include <stout/os.hpp>
+#include <stout/try.hpp>
+
// An abstraction around a socket (file descriptor) that provides
// reference counting such that the socket is only closed (and thus,
// has the possiblity of being reused) after there are no more
@@ -62,8 +68,9 @@ private:
if (__sync_sub_and_fetch(refs, 1) == 0) {
delete refs;
if (s >= 0) {
- if (close(s) != 0) {
- perror("Failed to close socket");
+ Try<Nothing> close = os::close(s);
+ if (close.isError()) {
+ std::cerr << "Failed to close socket: " << close.error() << std::endl;
abort();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/dcdc88b2/third_party/libprocess/src/encoder.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/encoder.hpp b/third_party/libprocess/src/encoder.hpp
index 12b3ffa..ec5e271 100644
--- a/third_party/libprocess/src/encoder.hpp
+++ b/third_party/libprocess/src/encoder.hpp
@@ -13,7 +13,7 @@
#include <stout/gzip.hpp>
#include <stout/hashmap.hpp>
#include <stout/numify.hpp>
-
+#include <stout/os.hpp>
namespace process {
@@ -218,7 +218,7 @@ public:
virtual ~FileEncoder()
{
- close(fd);
+ os::close(fd);
}
virtual Sender sender()
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/dcdc88b2/third_party/libprocess/src/httpd.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/httpd.cpp b/third_party/libprocess/src/httpd.cpp
index 49bcece..793a5b0 100644
--- a/third_party/libprocess/src/httpd.cpp
+++ b/third_party/libprocess/src/httpd.cpp
@@ -14,6 +14,8 @@
#include <arpa/inet.h>
+#include <stout/os.hpp>
+
#include "net.hpp"
#include "http-parser/http_parser.h"
@@ -145,7 +147,7 @@ protected:
if (fstat(fd, &fd_stat) < 0) {
send(HTTP_500, strlen(HTTP_500));
- close(fd);
+ os::close(fd);
return;
}
@@ -184,7 +186,7 @@ protected:
//cout << ht_id() << ": running " << this << " connection (4)" << endl;
- close(fd);
+ os::close(fd);
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/dcdc88b2/third_party/libprocess/src/net.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/net.hpp b/third_party/libprocess/src/net.hpp
index 8359526..2fdc62a 100644
--- a/third_party/libprocess/src/net.hpp
+++ b/third_party/libprocess/src/net.hpp
@@ -20,6 +20,8 @@
#include <stdexcept>
#include <iostream>
+#include <stout/os.hpp>
+
typedef enum Protocol { TCP = SOCK_STREAM, UDP = SOCK_DGRAM } Protocol;
using std::runtime_error;
@@ -155,7 +157,7 @@ public:
fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0))
throw runtime_error(string("ioctl/fcntl: ") += strerror(errno));
}
- ~SocketProcess() { ::close(s); }
+ ~SocketProcess() { os::close(s); }
};
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/dcdc88b2/third_party/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/process.cpp b/third_party/libprocess/src/process.cpp
index 197611f..edcb684 100644
--- a/third_party/libprocess/src/process.cpp
+++ b/third_party/libprocess/src/process.cpp
@@ -1097,7 +1097,7 @@ void accept(struct ev_loop* loop, ev_io* watcher, int revents)
if (nonblock.isError()) {
LOG_IF(INFO, VLOG_IS_ON(1)) << "Failed to accept, nonblock: "
<< nonblock.error();
- close(s);
+ os::close(s);
return;
}
@@ -1105,7 +1105,7 @@ void accept(struct ev_loop* loop, ev_io* watcher, int revents)
if (cloexec.isError()) {
LOG_IF(INFO, VLOG_IS_ON(1)) << "Failed to accept, cloexec: "
<< cloexec.error();
- close(s);
+ os::close(s);
return;
}
@@ -1114,7 +1114,7 @@ void accept(struct ev_loop* loop, ev_io* watcher, int revents)
if (setsockopt(s, SOL_TCP, TCP_NODELAY, &on, sizeof(on)) < 0) {
const char* error = strerror(errno);
VLOG(1) << "Failed to turn off the Nagle algorithm: " << error;
- close(s);
+ os::close(s);
} else {
// Inform the socket manager for proper bookkeeping.
const Socket& socket = socket_manager->accepted(s);
@@ -1437,7 +1437,7 @@ HttpProxy::~HttpProxy()
// Need to make sure response producers know not to continue to
// create a response (streaming or otherwise).
if (pipe.isSome()) {
- close(pipe.get());
+ os::close(pipe.get());
}
pipe = None();
@@ -1451,7 +1451,7 @@ HttpProxy::~HttpProxy()
if (item->future->isReady()) {
const Response& response = item->future->get();
if (response.type == Response::PIPE) {
- close(response.pipe);
+ os::close(response.pipe);
}
}
@@ -1667,7 +1667,7 @@ void HttpProxy::stream(const Future<short>& poll, const Request& request)
}
if (finished) {
- close(pipe.get());
+ os::close(pipe.get());
pipe = None();
next();
}