You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/06/16 00:40:01 UTC

[2/2] mesos git commit: Fixed http::Request::client to be set correctly.

Fixed http::Request::client to be set correctly.

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


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

Branch: refs/heads/master
Commit: c0536dbd9c1b4cf2d66af531b81567192e6af460
Parents: 77e2855
Author: Benjamin Mahler <be...@gmail.com>
Authored: Fri Jun 12 15:38:35 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jun 15 15:36:08 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/process.cpp          | 33 +++++++++++++++--------
 3rdparty/libprocess/src/tests/http_tests.cpp |  4 +--
 2 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c0536dbd/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index f919b99..a67a3af 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -570,22 +570,33 @@ void decode_recv(
   // Decode as much of the data as possible into HTTP requests.
   const deque<Request*> requests = decoder->decode(data, length.get());
 
+  if (requests.empty() && decoder->failed()) {
+     VLOG(1) << "Decoder error while receiving";
+     socket_manager->close(*socket);
+     delete[] data;
+     delete decoder;
+     delete socket;
+     return;
+  }
+
   if (!requests.empty()) {
+    // Get the peer address to augment the requests.
+    Try<Address> address = socket->peer();
+
+    if (address.isError()) {
+      VLOG(1) << "Failed to get peer address while receiving: "
+              << address.error();
+      socket_manager->close(*socket);
+      delete[] data;
+      delete decoder;
+      delete socket;
+      return;
+    }
+
     foreach (Request* request, requests) {
-      // Augment each Request with the client's address. This should
-      // never fail since there remains a reference to this Socket!
-      Try<Address> address = socket->address();
-      CHECK_SOME(address);
       request->client = address.get();
       process_manager->handle(decoder->socket(), request);
     }
-  } else if (requests.empty() && decoder->failed()) {
-    VLOG(1) << "Decoder error while receiving";
-    socket_manager->close(*socket);
-    delete[] data;
-    delete decoder;
-    delete socket;
-    return;
   }
 
   socket->recv(data, size)

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0536dbd/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 8444b9c..86b2c7d 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -369,7 +369,7 @@ TEST(HTTP, PathParse)
 
 http::Response validateGetWithoutQuery(const http::Request& request)
 {
-  EXPECT_NE(network::Address(), request.client);
+  EXPECT_NE(process::address(), request.client);
   EXPECT_EQ("GET", request.method);
   EXPECT_THAT(request.path, EndsWith("get"));
   EXPECT_EQ("", request.body);
@@ -382,7 +382,7 @@ http::Response validateGetWithoutQuery(const http::Request& request)
 
 http::Response validateGetWithQuery(const http::Request& request)
 {
-  EXPECT_NE(network::Address(), request.client);
+  EXPECT_NE(process::address(), request.client);
   EXPECT_EQ("GET", request.method);
   EXPECT_THAT(request.path, EndsWith("get"));
   EXPECT_EQ("", request.body);