This is an automated email from the ASF dual-hosted git repository. bennoe pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit c3db27280b29251c0b2ef29e6f9fca3efe43d5f4 Author: Benno Evers <[email protected]> AuthorDate: Wed Jun 19 15:44:47 2019 +0200 Renamed 'libprocess::network::Address::hostname()'. Renamed member function `hostname()` to `lookup_hostname()`, since the former name hides the fact that a call to this function involves a synchronous network access in order to make a reverse DNS lookup. Review: https://reviews.apache.org/r/70885 --- 3rdparty/libprocess/include/process/address.hpp | 10 ++++++++-- 3rdparty/libprocess/src/tests/http_tests.cpp | 6 +++--- 3rdparty/libprocess/src/tests/ssl_tests.cpp | 19 ++++++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/3rdparty/libprocess/include/process/address.hpp b/3rdparty/libprocess/include/process/address.hpp index e740e84..7494980 100644 --- a/3rdparty/libprocess/include/process/address.hpp +++ b/3rdparty/libprocess/include/process/address.hpp @@ -55,13 +55,19 @@ public: : ip(_ip), port(_port) {} /** - * Returns the hostname of this address's IP. + * Returns the hostname of this address's IP, + * using a reverse DNS lookup for remote addresses + * or the local hostname for a local address. * * @returns the hostname of this address's IP. */ // TODO(jmlvanre): Consider making this return a Future in order to // deal with slow name resolution. - Try<std::string> hostname() const + // + // TODO(bevers): A given IP can have multiple associated PTR records, + // (e.g. a shared web server hosting multiple domains), so the return + // value should probably be a list of strings. + Try<std::string> lookup_hostname() const { const Try<std::string> hostname = ip.isAny() ? net::hostname() diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp index 97aaf3e..4d37294 100644 --- a/3rdparty/libprocess/src/tests/http_tests.cpp +++ b/3rdparty/libprocess/src/tests/http_tests.cpp @@ -2218,7 +2218,7 @@ TEST_F(HttpServeTest, Pipelining) .WillOnce(DoAll(FutureArg<0>(&request3), Return(promise3.future()))) .WillRepeatedly(Return(http::OK())); - http::URL url("http", address.hostname().get(), address.port, "/"); + http::URL url("http", address.lookup_hostname().get(), address.port, "/"); http::Request request; request.method = "GET"; @@ -2313,7 +2313,7 @@ TEST_F(HttpServeTest, Discard) EXPECT_CALL(handler, handle(_)) .WillOnce(DoAll(FutureArg<0>(&request1), Return(promise1.future()))); - http::URL url("http", address.hostname().get(), address.port, "/"); + http::URL url("http", address.lookup_hostname().get(), address.port, "/"); http::Request request; request.method = "GET"; @@ -2450,7 +2450,7 @@ TEST(HttpServerTest, Pipeline) .WillOnce(DoAll(FutureArg<0>(&request3), Return(promise3.future()))) .WillRepeatedly(Return(http::OK())); - http::URL url("http", address->hostname().get(), address->port, "/"); + http::URL url("http", address->lookup_hostname().get(), address->port, "/"); http::Request request; request.method = "GET"; diff --git a/3rdparty/libprocess/src/tests/ssl_tests.cpp b/3rdparty/libprocess/src/tests/ssl_tests.cpp index 6b8496a..5d36022 100644 --- a/3rdparty/libprocess/src/tests/ssl_tests.cpp +++ b/3rdparty/libprocess/src/tests/ssl_tests.cpp @@ -551,13 +551,15 @@ TEST_F(SSLTest, HTTPSGet) ASSERT_SOME(server); ASSERT_SOME(server->address()); - ASSERT_SOME(server->address()->hostname()); + + Try<std::string> serverHostname = server->address()->lookup_hostname(); + ASSERT_SOME(serverHostname); Future<Socket> socket = server->accept(); // Create URL from server hostname and port. const http::URL url( - "https", server->address()->hostname().get(), server->address()->port); + "https", serverHostname.get(), server->address()->port); // Send GET request. Future<http::Response> response = http::get(url); @@ -589,13 +591,15 @@ TEST_F(SSLTest, HTTPSPost) ASSERT_SOME(server); ASSERT_SOME(server->address()); - ASSERT_SOME(server->address()->hostname()); + + Try<std::string> serverHostname = server->address()->lookup_hostname(); + ASSERT_SOME(serverHostname); Future<Socket> socket = server->accept(); // Create URL from server hostname and port. const http::URL url( - "https", server->address()->hostname().get(), server->address()->port); + "https", serverHostname.get(), server->address()->port); // Send POST request. Future<http::Response> response = @@ -631,7 +635,9 @@ TEST_F(SSLTest, SilentSocket) ASSERT_SOME(server); ASSERT_SOME(server->address()); - ASSERT_SOME(server->address()->hostname()); + + Try<std::string> serverHostname = server->address()->lookup_hostname(); + ASSERT_SOME(serverHostname); Future<Socket> socket = server->accept(); @@ -657,7 +663,7 @@ TEST_F(SSLTest, SilentSocket) // undergoing the SSL handshake. const http::URL url( "https", - server->address()->hostname().get(), + serverHostname.get(), server->address()->port); Future<http::Response> response = http::get(url); @@ -689,7 +695,6 @@ TEST_F(SSLTest, ShutdownThenSend) ASSERT_SOME(server); ASSERT_SOME(server->address()); - ASSERT_SOME(server->address()->hostname()); Future<Socket> socket = server->accept();
