-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/18001/#review34415
-----------------------------------------------------------

Ship it!


Thanks Nikita! I'll get this committed shortly, I've made a few minor edits for 
whitespace and logging. Also added Socket to the process namespace:

diff --git a/3rdparty/libprocess/include/process/socket.hpp 
b/3rdparty/libprocess/include/process/socket.hpp
index df3bb8c..dbcb4f4 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -10,8 +10,11 @@
 #include <stout/os.hpp>
 #include <stout/try.hpp>
 
+
 namespace process {
-// Small helper to create socket with the appropriate options
+
+// Returns a socket fd for the specified options. Note that on OS X,
+// the returned socket will have the SO_NOSIGPIPE option set.
 inline Try<int> socket(int family, int type, int protocol) {
   int s;
   if ((s = ::socket(family, type, protocol)) == -1) {
@@ -19,17 +22,17 @@ inline Try<int> socket(int family, int type, int protocol) {
   }
 
 #ifdef __APPLE__
-
-  // Disable SIGPIPE via setsockopt because MAC OS
-  // doesn't support MSG_NOSIGNAL flag on send.
+  // Disable SIGPIPE via setsockopt because OS X does not support
+  // the MSG_NOSIGNAL flag on send(2).
   const int enable = 1;
   if (setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &enable, sizeof(int)) == -1) {
     return ErrnoError();
   }
 #endif // __APPLE__
+
   return s;
 }
-}
+
 
 // An abstraction around a socket (file descriptor) that provides
 // reference counting such that the socket is only closed (and thus,
@@ -102,4 +105,6 @@ private:
   int s;
 };
 
+} // namespace process {
+
 #endif // __PROCESS_SOCKET_HPP__
diff --git a/3rdparty/libprocess/src/process.cpp 
b/3rdparty/libprocess/src/process.cpp
index 10b2e84..7bf2d70 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1891,11 +1891,10 @@ void SocketManager::link(ProcessBase* process, const 
UPID& to)
     // Check if node is remote and there isn't a persistant link.
     if ((node.ip != __ip__ || node.port != __port__)
         && persists.count(node) == 0) {
-      // Okay, no link, lets create a socket.
-
+      // Okay, no link, let's create a socket.
       Try<int> socket = process::socket(AF_INET, SOCK_STREAM, 0);
       if (socket.isError()) {
-        PLOG(FATAL) << "Failed to link, socket";
+        LOG(FATAL) << "Failed to link, socket: " << socket.error();
       }
 
       int s = socket.get();
@@ -2059,11 +2058,11 @@ void SocketManager::send(Message* message)
       CHECK(sockets.count(s) > 0);
       send(new MessageEncoder(sockets[s], message), persist);
     } else {
-      // No peristant or temporary socket to the node currently
+      // No peristent or temporary socket to the node currently
       // exists, so we create a temporary one.
       Try<int> socket = process::socket(AF_INET, SOCK_STREAM, 0);
       if (socket.isError()) {
-        PLOG(FATAL) << "Failed to send, socket";
+        LOG(FATAL) << "Failed to send, socket: " << socket.error();
       }
 
       int s = socket.get();
@@ -3943,7 +3942,7 @@ Future<Response> request(
   Try<int> socket = process::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
 
   if (socket.isError()) {
-    return Failure(string("Failed to create socket: ") + socket.error());
+    return Failure("Failed to create socket: " + socket.error());
   }
 
   int s = socket.get();


- Ben Mahler


On Feb. 13, 2014, 7:06 a.m., Nikita Vetoshkin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/18001/
> -----------------------------------------------------------
> 
> (Updated Feb. 13, 2014, 7:06 a.m.)
> 
> 
> Review request for mesos.
> 
> 
> Bugs: MESOS-912
>     https://issues.apache.org/jira/browse/MESOS-912
> 
> 
> Repository: mesos-git
> 
> 
> Description
> -------
> 
> Following the discussion in JIRA - disable SIGPIPE on MacOS via setsockopt as 
> it doesn't support MSG_NOSIGNAL.
> 
> 
> Diffs
> -----
> 
>   3rdparty/libprocess/include/process/socket.hpp 
> 669a3334629e15b420ea8332e31cd0306d52066b 
>   3rdparty/libprocess/src/process.cpp 
> 2e7764a8e0badec704b8610f3f72f0bd16cc9612 
>   3rdparty/libprocess/src/tests/http_tests.cpp 
> 62ab64d81c11ab7260620c91100b7e1f29b81e33 
>   3rdparty/libprocess/src/tests/process_tests.cpp 
> be288c353dce78ef641708646979e2e4f3f2c504 
> 
> Diff: https://reviews.apache.org/r/18001/diff/
> 
> 
> Testing
> -------
> 
> None.
> 
> 
> Thanks,
> 
> Nikita Vetoshkin
> 
>

Reply via email to