summaryrefslogtreecommitdiff
path: root/sql/hostname.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-01-23 01:25:07 +0200
committerunknown <monty@donna.mysql.com>2001-01-23 01:25:07 +0200
commit6370f97b2c9d2fe26be653d1031b918cf097d08e (patch)
tree8bbe5c1f42df3580477789560dc9f52df1d4a2fc /sql/hostname.cc
parent3e54e5393293426a9bfb7e6036f7e12bdb71d3b5 (diff)
downloadmariadb-git-6370f97b2c9d2fe26be653d1031b918cf097d08e.tar.gz
Added new mutex for hostname lookup
Added free of io_cache when using ALTER TABLE ... ORDER BY Docs/manual.texi: Updated from user comments sql/ha_berkeley.cc: Fixed wrong cast sql/hostname.cc: Added new mutex for hostname lookup sql/sql_table.cc: 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));