You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2016/11/29 21:29:46 UTC

[13/14] mesos git commit: Added support for specifying how a socket should be shutdown.

Added support for specifying how a socket should be shutdown.

Review: https://reviews.apache.org/r/54113


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4417a4e8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4417a4e8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4417a4e8

Branch: refs/heads/master
Commit: 4417a4e8917e17e70942a77bd796857978778888
Parents: b3013ff
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sun Nov 27 12:10:14 2016 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Nov 29 12:19:17 2016 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/socket.hpp | 27 ++++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4417a4e8/3rdparty/libprocess/include/process/socket.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/socket.hpp b/3rdparty/libprocess/include/process/socket.hpp
index 7f489e9..e9e89ee 100644
--- a/3rdparty/libprocess/include/process/socket.hpp
+++ b/3rdparty/libprocess/include/process/socket.hpp
@@ -183,11 +183,9 @@ public:
    * Shutdown the receive-side of the socket. No further data can be
    * received from the socket.
    */
-  // TODO(neilc): Change this to allow the caller to specify `how`.
-  // See MESOS-5658.
-  virtual Try<Nothing> shutdown()
+  virtual Try<Nothing> shutdown(int how)
   {
-    if (::shutdown(s, SHUT_RD) < 0) {
+    if (::shutdown(s, how) < 0) {
       return ErrnoError();
     }
 
@@ -380,9 +378,26 @@ public:
     return impl->send(data);
   }
 
-  Try<Nothing> shutdown()
+  enum class Shutdown
   {
-    return impl->shutdown();
+    READ,
+    WRITE,
+    READ_WRITE
+  };
+
+  // TODO(benh): Replace the default to Shutdown::READ_WRITE or remove
+  // all together since it's unclear what the defauilt should be.
+  Try<Nothing> shutdown(Shutdown shutdown = Shutdown::READ)
+  {
+    int how = [&]() {
+      switch (shutdown) {
+        case Shutdown::READ: return SHUT_RD;
+        case Shutdown::WRITE: return SHUT_WR;
+        case Shutdown::READ_WRITE: return SHUT_RDWR;
+      }
+    }();
+
+    return impl->shutdown(how);
   }
 
   // Support implicit conversion of any `Socket<AddressType>` to a