summaryrefslogtreecommitdiff
path: root/sql/hostname.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-01-23 01:26:11 +0200
committerunknown <monty@donna.mysql.com>2001-01-23 01:26:11 +0200
commit060cd1a1376027c120b274932edd1c512dabe39d (patch)
tree5cb455b5effaff53e167b5de4e375a43df0dabaf /sql/hostname.cc
parente4667fc51861263cdc46f59cb09d6def8edd6daf (diff)
parent6370f97b2c9d2fe26be653d1031b918cf097d08e (diff)
downloadmariadb-git-060cd1a1376027c120b274932edd1c512dabe39d.tar.gz
Merge work:/my/mysql into donna.mysql.com:/home/my/bk/mysql
Diffstat (limited to 'sql/hostname.cc')
-rw-r--r--sql/hostname.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/hostname.cc b/sql/hostname.cc
index fcf8d2753b8..0112bb884f3 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -48,6 +48,7 @@ public:
};
static hash_filo *hostname_cache;
+static pthread_mutex_t LOCK_hostname;
void hostname_cache_refresh()
{
@@ -56,6 +57,7 @@ void hostname_cache_refresh()
bool hostname_cache_init()
{
+ (void) pthread_mutex_init(&LOCK_hostname,NULL);
if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE,offsetof(host_entry,ip),
sizeof(struct in_addr),NULL,
(void (*)(void*)) free)))
@@ -66,6 +68,7 @@ bool hostname_cache_init()
void hostname_cache_free()
{
+ (void) pthread_mutex_destroy(&LOCK_hostname);
delete hostname_cache;
}
@@ -180,26 +183,26 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
DBUG_RETURN(0); // out of memory
#else
- VOID(pthread_mutex_lock(&hostname_cache->lock));
+ VOID(pthread_mutex_lock(&LOCK_hostname));
if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET)))
{
- VOID(pthread_mutex_unlock(&hostname_cache->lock));
+ VOID(pthread_mutex_unlock(&LOCK_hostname));
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
goto err;
}
if (!hp->h_name[0]) // Don't allow empty hostnames
{
- VOID(pthread_mutex_unlock(&hostname_cache->lock));
+ VOID(pthread_mutex_unlock(&LOCK_hostname));
DBUG_PRINT("error",("Got an empty hostname"));
goto err;
}
if (!(name=my_strdup(hp->h_name,MYF(0))))
{
- VOID(pthread_mutex_unlock(&hostname_cache->lock));
+ VOID(pthread_mutex_unlock(&LOCK_hostname));
DBUG_RETURN(0); // out of memory
}
check=gethostbyname(name);
- VOID(pthread_mutex_unlock(&hostname_cache->lock));
+ VOID(pthread_mutex_unlock(&LOCK_hostname));
if (!check)
{
DBUG_PRINT("error",("gethostbyname returned %d",errno));