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 2016/11/29 21:29:42 UTC
[09/14] mesos git commit: Inlined function only used one place.
Inlined function only used one place.
Review: https://reviews.apache.org/r/53461
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2529d077
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2529d077
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2529d077
Branch: refs/heads/master
Commit: 2529d077a6a1603f7689a684a1e946f16e474006
Parents: 4694267
Author: Benjamin Hindman <be...@gmail.com>
Authored: Thu Nov 3 23:37:40 2016 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Tue Nov 29 12:06:29 2016 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/net.hpp | 48 ++++++++++++++-----------------
1 file changed, 21 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2529d077/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/net.hpp b/3rdparty/stout/include/stout/net.hpp
index 083b8d1..4803aeb 100644
--- a/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/stout/include/stout/net.hpp
@@ -198,32 +198,6 @@ inline struct addrinfo createAddrInfo(int socktype, int family, int flags)
}
-// TODO(evelinad): Move this to Address.
-inline struct sockaddr_storage createSockaddrStorage(const IP& ip, int port)
-{
- struct sockaddr_storage storage;
- memset(&storage, 0, sizeof(storage));
-
- switch (ip.family()) {
- case AF_INET: {
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr = ip.in().get();
- addr.sin_port = htons(port);
-
- memcpy(&storage, &addr, sizeof(addr));
- break;
- }
- default: {
- ABORT("Unsupported family type: " + stringify(ip.family()));
- }
- }
-
- return storage;
-}
-
-
inline Try<std::string> hostname()
{
char host[512];
@@ -252,9 +226,29 @@ inline Try<std::string> hostname()
// Returns a Try of the hostname for the provided IP. If the hostname
// cannot be resolved, then a string version of the IP address is
// returned.
+//
+// TODO(benh): Merge with `net::hostname`.
inline Try<std::string> getHostname(const IP& ip)
{
- struct sockaddr_storage storage = createSockaddrStorage(ip, 0);
+ struct sockaddr_storage storage;
+ memset(&storage, 0, sizeof(storage));
+
+ switch (ip.family()) {
+ case AF_INET: {
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr = ip.in().get();
+ addr.sin_port = 0;
+
+ memcpy(&storage, &addr, sizeof(addr));
+ break;
+ }
+ default: {
+ ABORT("Unsupported family type: " + stringify(ip.family()));
+ }
+ }
+
char hostname[MAXHOSTNAMELEN];
int error = getnameinfo(