diff options
author | monty@hundin.mysql.fi <> | 2002-06-03 12:59:31 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2002-06-03 12:59:31 +0300 |
commit | f0b28da6f91cf87804015b5dde4820be040c2de7 (patch) | |
tree | be04186411dc657ef6bbcbe01267d30f2675c914 /sql/hostname.cc | |
parent | 3ede8f6289b53345f44aecffd70c7e291f88186b (diff) | |
parent | 544f95c45112993df1d31d3eda859dd5e4efff89 (diff) | |
download | mariadb-git-f0b28da6f91cf87804015b5dde4820be040c2de7.tar.gz |
merge with 4.0
Diffstat (limited to 'sql/hostname.cc')
-rw-r--r-- | sql/hostname.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/hostname.cc b/sql/hostname.cc index 0b35f970c42..0a9be8a3213 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -57,8 +57,11 @@ void hostname_cache_refresh() bool hostname_cache_init() { + host_entry *tmp; + uint offset= (uint) ((char*) (&tmp->ip) - (char*) &tmp); (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW); - if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE,offsetof(host_entry,ip), + + if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset, sizeof(struct in_addr),NULL, (void (*)(void*)) free))) return 1; @@ -171,17 +174,22 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) { DBUG_PRINT("error",("gethostbyname_r returned %d",tmp_errno)); add_wrong_ip(in); + my_gethostbyname_r_free(); DBUG_RETURN(0); } if (!hp->h_name[0]) { DBUG_PRINT("error",("Got an empty hostname")); add_wrong_ip(in); + my_gethostbyname_r_free(); DBUG_RETURN(0); // Don't allow empty hostnames } if (!(name=my_strdup(hp->h_name,MYF(0)))) + { + my_gethostbyname_r_free(); DBUG_RETURN(0); // out of memory - + } + my_gethostbyname_r_free(); #else VOID(pthread_mutex_lock(&LOCK_hostname)); if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET))) |