summaryrefslogtreecommitdiff
path: root/sql/hostname.cc
diff options
context:
space:
mode:
authormonty@donna.mysql.com <>2001-01-23 01:25:07 +0200
committermonty@donna.mysql.com <>2001-01-23 01:25:07 +0200
commit877386602a0ca57e794bb95a3dae0c6cd4afabfd (patch)
tree8bbe5c1f42df3580477789560dc9f52df1d4a2fc /sql/hostname.cc
parentb3392db2900435caebf9d1b56d17a44db7c203cc (diff)
downloadmariadb-git-877386602a0ca57e794bb95a3dae0c6cd4afabfd.tar.gz
Added new mutex for hostname lookup
Added free of io_cache when using ALTER TABLE ... ORDER BY
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));