mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 10:31:54 +01:00
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:
parent
72d7b12b9c
commit
16c446235e
4 changed files with 13 additions and 21 deletions
|
@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
|
||||||
|
|
||||||
push @::global_suppressions,
|
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: wsrep_sst_receive_address is set to '127.0.0.1),
|
||||||
qr(WSREP: Could not open saved state file for reading: ),
|
qr(WSREP: Could not open saved state file for reading: ),
|
||||||
qr(WSREP: Gap in state sequence. Need state transfer.),
|
qr(WSREP: Gap in state sequence. Need state transfer.),
|
||||||
|
|
|
@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
|
||||||
|
|
||||||
push @::global_suppressions,
|
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: Could not open saved state file for reading: ),
|
||||||
qr(WSREP: option --wsrep-casual-reads is deprecated),
|
qr(WSREP: option --wsrep-casual-reads is deprecated),
|
||||||
qr(WSREP: --wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=0),
|
qr(WSREP: --wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=0),
|
||||||
|
|
|
@ -35,8 +35,9 @@
|
||||||
#include <netdb.h> // getaddrinfo()
|
#include <netdb.h> // getaddrinfo()
|
||||||
|
|
||||||
#ifdef HAVE_GETIFADDRS
|
#ifdef HAVE_GETIFADDRS
|
||||||
|
#include <net/if.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#endif
|
#endif /* HAVE_GETIFADDRS */
|
||||||
|
|
||||||
extern char** environ; // environment variables
|
extern char** environ; // environment variables
|
||||||
|
|
||||||
|
@ -406,6 +407,13 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
|
||||||
return ip_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
|
#if HAVE_GETIFADDRS
|
||||||
struct ifaddrs *ifaddr, *ifa;
|
struct ifaddrs *ifaddr, *ifa;
|
||||||
if (getifaddrs(&ifaddr) == 0)
|
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
|
if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_INET) // TODO AF_INET6
|
||||||
continue;
|
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;
|
continue;
|
||||||
|
|
||||||
if (strcmp(buf, "127.0.0.1") == 0) // lame
|
if (vio_getnameinfo(ifa->ifa_addr, buf, buf_len, NULL, 0, NI_NUMERICHOST))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
freeifaddrs(ifaddr);
|
freeifaddrs(ifaddr);
|
||||||
|
@ -426,23 +435,11 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
|
||||||
}
|
}
|
||||||
freeifaddrs(ifaddr);
|
freeifaddrs(ifaddr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* HAVE_GETIFADDRS */
|
||||||
|
|
||||||
return 0;
|
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
|
* WSREPXid
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
unsigned int wsrep_check_ip (const char* addr);
|
unsigned int wsrep_check_ip (const char* addr);
|
||||||
size_t wsrep_guess_ip (char* buf, size_t buf_len);
|
size_t wsrep_guess_ip (char* buf, size_t buf_len);
|
||||||
size_t wsrep_guess_address(char* buf, size_t buf_len);
|
|
||||||
|
|
||||||
namespace wsp {
|
namespace wsp {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue