Changes in wsrep_guess_ip()

* Changed loopback detection to be done via ifa->ifa_flags
* Removed unused function wsrep_guess_address()
This commit is contained in:
Nirbhay Choubey 2015-02-24 21:55:22 -05:00
parent 72d7b12b9c
commit 16c446235e
4 changed files with 13 additions and 21 deletions

View file

@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
push @::global_suppressions,
(
qr(WSREP: Failed to guess base node address),
qr(WSREP: Guessing address for incoming client connections failed),
qr(WSREP: wsrep_sst_receive_address is set to '127.0.0.1),
qr(WSREP: Could not open saved state file for reading: ),
qr(WSREP: Gap in state sequence. Need state transfer.),

View file

@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
push @::global_suppressions,
(
qr(WSREP: Failed to guess base node address),
qr(WSREP: Guessing address for incoming client connections failed),
qr(WSREP: Could not open saved state file for reading: ),
qr(WSREP: option --wsrep-casual-reads is deprecated),
qr(WSREP: --wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=0),

View file

@ -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
*/

View file

@ -21,7 +21,6 @@
unsigned int wsrep_check_ip (const char* addr);
size_t wsrep_guess_ip (char* buf, size_t buf_len);
size_t wsrep_guess_address(char* buf, size_t buf_len);
namespace wsp {