diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-24 21:55:22 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-27 17:43:10 -0500 |
commit | 8ee5668033ed9f4c59cd5bf0b995dd77d326fe36 (patch) | |
tree | 44a843570a001dd15f91f92b5568bf477edc11c0 /sql/wsrep_utils.cc | |
parent | af651c80f7d7b49a141958a68e81f2de90e62f25 (diff) | |
download | mariadb-git-8ee5668033ed9f4c59cd5bf0b995dd77d326fe36.tar.gz |
Changes in wsrep_guess_ip()
* Changed loopback detection to be done via ifa->ifa_flags
* Removed unused function wsrep_guess_address()
Diffstat (limited to 'sql/wsrep_utils.cc')
-rw-r--r-- | sql/wsrep_utils.cc | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 545870f1c07..f30b3dcf702 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -35,8 +35,9 @@ #include <netdb.h> // getaddrinfo() #ifdef HAVE_GETIFADDRS +#include <net/if.h> #include <ifaddrs.h> -#endif +#endif /* HAVE_GETIFADDRS */ extern char** environ; // environment variables @@ -406,6 +407,13 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len) return ip_len; } + /* + getifaddrs() is avaiable at least on Linux since glib 2.3, FreeBSD, + MAC OSX, OpenSolaris, Solaris. + + On platforms which do not support getifaddrs() this function returns + a failure and user is prompted to do manual configuration. + */ #if HAVE_GETIFADDRS struct ifaddrs *ifaddr, *ifa; if (getifaddrs(&ifaddr) == 0) @@ -415,10 +423,11 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len) if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_INET) // TODO AF_INET6 continue; - if (vio_getnameinfo(ifa->ifa_addr, buf, buf_len, NULL, 0, NI_NUMERICHOST)) + // Skip loopback interfaces (like lo:127.0.0.1) + if (ifa->ifa_flags & IFF_LOOPBACK) continue; - if (strcmp(buf, "127.0.0.1") == 0) // lame + if (vio_getnameinfo(ifa->ifa_addr, buf, buf_len, NULL, 0, NI_NUMERICHOST)) continue; freeifaddrs(ifaddr); @@ -426,23 +435,11 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len) } freeifaddrs(ifaddr); } -#endif +#endif /* HAVE_GETIFADDRS */ return 0; } -size_t wsrep_guess_address(char* buf, size_t buf_len) -{ - size_t addr_len = wsrep_guess_ip (buf, buf_len); - - if (addr_len && addr_len < buf_len) { - addr_len += snprintf (buf + addr_len, buf_len - addr_len, - ":%u", mysqld_port); - } - - return addr_len; -} - /* * WSREPXid */ |