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 2017/05/30 20:23:58 UTC

mesos git commit: Add local and peer address accessors to http::Connection.

Repository: mesos
Updated Branches:
  refs/heads/master 8fb22bf4b -> 12b80ee43


Add local and peer address accessors to http::Connection.

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


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

Branch: refs/heads/master
Commit: 12b80ee43a7f652719ee80f6b4108df529509ab0
Parents: 8fb22bf
Author: James Peach <jp...@apache.org>
Authored: Tue May 30 13:13:28 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Tue May 30 13:13:28 2017 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp |  9 ++++++++-
 3rdparty/libprocess/src/http.cpp             | 18 ++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/12b80ee4/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 650b9d8..f637999 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -960,8 +960,15 @@ public:
   bool operator==(const Connection& c) const { return data == c.data; }
   bool operator!=(const Connection& c) const { return !(*this == c); }
 
+  const network::Address localAddress;
+  const network::Address peerAddress;
+
 private:
-  Connection(const network::Socket& s);
+  Connection(
+      const network::Socket& s,
+      const network::Address& _localAddress,
+      const network::Address& _peerAddress);
+
   friend Future<Connection> connect(
       const network::Address& address, Scheme scheme);
   friend Future<Connection> connect(const URL&);

http://git-wip-us.apache.org/repos/asf/mesos/blob/12b80ee4/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 9789607..f317f2f 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -1349,8 +1349,12 @@ struct Connection::Data
 };
 
 
-Connection::Connection(const network::Socket& s)
-  : data(std::make_shared<Connection::Data>(s)) {}
+Connection::Connection(
+    const network::Socket& s,
+    const network::Address& _localAddress,
+    const network::Address& _peerAddress)
+  : localAddress(_localAddress), peerAddress(_peerAddress),
+    data(std::make_shared<Connection::Data>(s)) {}
 
 
 Future<Response> Connection::send(
@@ -1405,8 +1409,14 @@ Future<Connection> connect(const network::Address& address, Scheme scheme)
   }
 
   return socket->connect(address)
-    .then([socket]() {
-      return Connection(socket.get());
+    .then([socket, address]() -> Future<Connection> {
+      Try<network::Address> localAddress = socket->address();
+      if (localAddress.isError()) {
+        return Failure("Failed to get socket's local address: " +
+            localAddress.error());
+      }
+
+      return Connection(socket.get(), localAddress.get(), address);
     });
 }