diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-24 21:55:22 -0500 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-02-27 19:16:27 -0500 |
commit | 16c446235ecba3abeaee0fa8e433d882ee833cd7 (patch) | |
tree | 7005cddd4879222e98876f6bcf0635925123d564 /sql/wsrep_utils.cc | |
parent | 72d7b12b9c9c5ceffef9fff3adc86c149f57f20f (diff) | |
download | mariadb-git-16c446235ecba3abeaee0fa8e433d882ee833cd7.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 2c3fc0d77fd..7172f77bfed 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 */ |