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/05/20 00:10:06 UTC
[2/2] mesos git commit: Style fixes for net::getIP.
Style fixes for net::getIP.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d59fb382
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d59fb382
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d59fb382
Branch: refs/heads/master
Commit: d59fb38223156e46a37a00d79ca21b0993ad03c9
Parents: 08e11d3
Author: Benjamin Mahler <be...@gmail.com>
Authored: Tue May 19 15:07:25 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Tue May 19 15:07:25 2015 -0700
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d59fb382/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
index cf0090b..0c09b34 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
@@ -190,22 +190,25 @@ inline Try<std::string> getHostname(const IP& ip)
// obtained.
inline Try<IP> getIP(const std::string& hostname, int family)
{
- struct addrinfo hints;
+ struct addrinfo hints = createAddrInfo(SOCK_STREAM, family, 0);
struct addrinfo* result = NULL;
- hints = createAddrInfo(SOCK_STREAM, family, 0);
+
int error = getaddrinfo(hostname.c_str(), NULL, &hints, &result);
+
if (error != 0) {
return Error(gai_strerror(error));
}
+
if (result->ai_addr == NULL) {
freeaddrinfo(result);
- return Error("Got no addresses for '" + hostname + "'");
+ return Error("No addresses found");
}
Try<IP> ip = IP::create(*result->ai_addr);
+
if (ip.isError()) {
freeaddrinfo(result);
- return Error("Unsupported family type: " + stringify(family));
+ return Error("Unsupported family type");
}
freeaddrinfo(result);