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 2017/02/04 07:46:47 UTC

[3/6] mesos git commit: Replaced recursive implementation in http::Connection with loop.

Replaced recursive implementation in http::Connection with loop.

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


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

Branch: refs/heads/master
Commit: 0fbc04b4fcd4564405353e53cc2e049e25ed5fe0
Parents: f200f89
Author: Benjamin Hindman <be...@gmail.com>
Authored: Sat Jan 14 13:20:20 2017 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Fri Feb 3 23:44:26 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/http.cpp | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0fbc04b4/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 439840a..544c26f 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -1259,15 +1259,20 @@ protected:
 private:
   static Future<Nothing> _send(network::Socket socket, Pipe::Reader reader)
   {
-    return reader.read()
-      .then([socket, reader](const string& data) mutable -> Future<Nothing> {
-        if (data.empty()) {
-          return Nothing(); // EOF.
-        }
-
-        return socket.send(data)
-          .then(lambda::bind(_send, socket, reader));
-      });
+    return loop(
+        None(),
+        [=]() mutable {
+          return reader.read();
+        },
+        [=](const string& data) mutable -> Future<ControlFlow<Nothing>> {
+          if (data.empty()) {
+            return Break(); // EOF.
+          }
+          return socket.send(data)
+            .then([]() -> ControlFlow<Nothing> {
+              return Continue();
+            });
+        });
   }
 
   void read()