diff options
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r-- | libmysql/libmysql.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index ffce5f6bce7..4190a4c37f4 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1312,7 +1312,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr)); } else -#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD) { int tmp_errno; struct hostent tmp_hostent,*hp; @@ -1323,22 +1322,12 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, { net->last_errno=CR_UNKNOWN_HOST; sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno); + my_gethostbyname_r_free(); goto error; } memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); + my_gethostbyname_r_free(); } -#else - { - struct hostent *hp; - if (!(hp=gethostbyname(host))) - { - net->last_errno=CR_UNKNOWN_HOST; - sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno); - goto error; - } - memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); - } -#endif sock_addr.sin_port = (ushort) htons((ushort) port); if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), mysql->options.connect_timeout) <0) |