Skip to content

Commit 627caa3

Browse files
author
Sergei Golubchik
committed
fix the error message when getaddrinfo() fails. on windows "*" doesn't mean "any address"
1 parent 75f0f17 commit 627caa3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sql/mysqld.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,7 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
23662366
int error;
23672367
int arg;
23682368
char port_buf[NI_MAXSERV];
2369+
const char *real_bind_addr_str;
23692370
MYSQL_SOCKET ip_sock= MYSQL_INVALID_SOCKET;
23702371
DBUG_ENTER("activate_tcp_port");
23712372
DBUG_PRINT("general",("IP Socket is %d",port));
@@ -2374,13 +2375,19 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
23742375
hints.ai_flags= AI_PASSIVE;
23752376
hints.ai_socktype= SOCK_STREAM;
23762377
hints.ai_family= AF_UNSPEC;
2378+
2379+
if (my_bind_addr_str && strcmp(my_bind_addr_str, "*") == 0)
2380+
real_bind_addr_str= NULL; // windows doesn't seem to support * here
2381+
else
2382+
real_bind_addr_str= my_bind_addr_str;
23772383

23782384
my_snprintf(port_buf, NI_MAXSERV, "%d", port);
2379-
error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
2385+
error= getaddrinfo(real_bind_addr_str, port_buf, &hints, &ai);
23802386
if (error != 0)
23812387
{
23822388
DBUG_PRINT("error",("Got error: %d from getaddrinfo()", error));
2383-
sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
2389+
2390+
sql_print_error("%s: %s", ER_DEFAULT(ER_IPSOCK_ERROR), gai_strerror(error));
23842391
unireg_abort(1); /* purecov: tested */
23852392
}
23862393

@@ -2389,8 +2396,7 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
23892396
because we later switch off IPV6_V6ONLY, so ipv6 wildcard
23902397
addresses will work for ipv4 too
23912398
*/
2392-
if ((my_bind_addr_str == NULL || strcmp(my_bind_addr_str, "*") == 0)
2393-
&& ai->ai_family == AF_INET && ai->ai_next
2399+
if (!real_bind_addr_str && ai->ai_family == AF_INET && ai->ai_next
23942400
&& ai->ai_next->ai_family == AF_INET6)
23952401
{
23962402
a= ai;

0 commit comments

Comments
 (0)