diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-03 16:43:03 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-03 16:43:03 +0300 |
commit | b92ab41c5c380448422bd776c73fddfd5c7507f6 (patch) | |
tree | 3b69ab5126c40ef71ad69a5bb469de82c4be90a0 /sql/sql_cache.cc | |
parent | dfc15e2acc9312c3357b6149feb771c724ba8252 (diff) | |
parent | a4c3bc618bb83884a19dc157bc56d4e3d2432c22 (diff) | |
download | mariadb-git-b92ab41c5c380448422bd776c73fddfd5c7507f6.tar.gz |
Merge next-mr -> next-4284
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 695ae3fb567..f812ef862b0 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -341,18 +341,14 @@ TODO list: #endif #if !defined(EXTRA_DBUG) && !defined(DBUG_OFF) -#define MUTEX_LOCK(M) { DBUG_PRINT("lock", ("mutex lock 0x%lx", (ulong)(M))); \ - pthread_mutex_lock(M);} -#define MUTEX_UNLOCK(M) {DBUG_PRINT("lock", ("mutex unlock 0x%lx",\ - (ulong)(M))); pthread_mutex_unlock(M);} #define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \ - if (!rw_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \ + if (!mysql_rwlock_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \ else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); } #define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock 0x%lx", (ulong)(M))); \ - if (!rw_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \ + if (!mysql_rwlock_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \ else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); } #define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock 0x%lx",(ulong)(M))); \ - if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \ + if (!mysql_rwlock_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \ else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); } #define BLOCK_LOCK_WR(B) {DBUG_PRINT("lock", ("%d LOCK_WR 0x%lx",\ __LINE__,(ulong)(B))); \ @@ -395,11 +391,9 @@ static void debug_wait_for_kill(const char *info) } #else -#define MUTEX_LOCK(M) pthread_mutex_lock(M) -#define MUTEX_UNLOCK(M) pthread_mutex_unlock(M) -#define RW_WLOCK(M) rw_wrlock(M) -#define RW_RLOCK(M) rw_rdlock(M) -#define RW_UNLOCK(M) rw_unlock(M) +#define RW_WLOCK(M) mysql_rwlock_wrlock(M) +#define RW_RLOCK(M) mysql_rwlock_rdlock(M) +#define RW_UNLOCK(M) mysql_rwlock_unlock(M) #define BLOCK_LOCK_WR(B) B->query()->lock_writing() #define BLOCK_LOCK_RD(B) B->query()->lock_reading() #define BLOCK_UNLOCK_WR(B) B->query()->unlock_writing() @@ -430,7 +424,7 @@ bool Query_cache::try_lock(bool use_timeout) bool interrupt= FALSE; DBUG_ENTER("Query_cache::try_lock"); - pthread_mutex_lock(&structure_guard_mutex); + mysql_mutex_lock(&structure_guard_mutex); while (1) { if (m_cache_lock_status == Query_cache::UNLOCKED) @@ -463,8 +457,8 @@ bool Query_cache::try_lock(bool use_timeout) { struct timespec waittime; set_timespec_nsec(waittime,(ulong)(50000000L)); /* Wait for 50 msec */ - int res= pthread_cond_timedwait(&COND_cache_status_changed, - &structure_guard_mutex,&waittime); + int res= mysql_cond_timedwait(&COND_cache_status_changed, + &structure_guard_mutex, &waittime); if (res == ETIMEDOUT) { interrupt= TRUE; @@ -473,11 +467,11 @@ bool Query_cache::try_lock(bool use_timeout) } else { - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + mysql_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); } } } - pthread_mutex_unlock(&structure_guard_mutex); + mysql_mutex_unlock(&structure_guard_mutex); DBUG_RETURN(interrupt); } @@ -498,9 +492,9 @@ void Query_cache::lock_and_suspend(void) { DBUG_ENTER("Query_cache::lock_and_suspend"); - pthread_mutex_lock(&structure_guard_mutex); + mysql_mutex_lock(&structure_guard_mutex); while (m_cache_lock_status != Query_cache::UNLOCKED) - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + mysql_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); m_cache_lock_status= Query_cache::LOCKED_NO_WAIT; #ifndef DBUG_OFF THD *thd= current_thd; @@ -508,8 +502,8 @@ void Query_cache::lock_and_suspend(void) m_cache_lock_thread_id= thd->thread_id; #endif /* Wake up everybody, a whole cache flush is starting! */ - pthread_cond_broadcast(&COND_cache_status_changed); - pthread_mutex_unlock(&structure_guard_mutex); + mysql_cond_broadcast(&COND_cache_status_changed); + mysql_mutex_unlock(&structure_guard_mutex); DBUG_VOID_RETURN; } @@ -526,16 +520,16 @@ void Query_cache::lock(void) { DBUG_ENTER("Query_cache::lock"); - pthread_mutex_lock(&structure_guard_mutex); + mysql_mutex_lock(&structure_guard_mutex); while (m_cache_lock_status != Query_cache::UNLOCKED) - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + mysql_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); m_cache_lock_status= Query_cache::LOCKED; #ifndef DBUG_OFF THD *thd= current_thd; if (thd) m_cache_lock_thread_id= thd->thread_id; #endif - pthread_mutex_unlock(&structure_guard_mutex); + mysql_mutex_unlock(&structure_guard_mutex); DBUG_VOID_RETURN; } @@ -548,7 +542,7 @@ void Query_cache::lock(void) void Query_cache::unlock(void) { DBUG_ENTER("Query_cache::unlock"); - pthread_mutex_lock(&structure_guard_mutex); + mysql_mutex_lock(&structure_guard_mutex); #ifndef DBUG_OFF THD *thd= current_thd; if (thd) @@ -558,8 +552,8 @@ void Query_cache::unlock(void) m_cache_lock_status == Query_cache::LOCKED_NO_WAIT); m_cache_lock_status= Query_cache::UNLOCKED; DBUG_PRINT("Query_cache",("Sending signal")); - pthread_cond_signal(&COND_cache_status_changed); - pthread_mutex_unlock(&structure_guard_mutex); + mysql_cond_signal(&COND_cache_status_changed); + mysql_mutex_unlock(&structure_guard_mutex); DBUG_VOID_RETURN; } @@ -728,7 +722,7 @@ inline void Query_cache_query::lock_writing() my_bool Query_cache_query::try_lock_writing() { DBUG_ENTER("Query_cache_block::try_lock_writing"); - if (rw_trywrlock(&lock)!=0) + if (mysql_rwlock_trywrlock(&lock) != 0) { DBUG_PRINT("info", ("can't lock rwlock")); DBUG_RETURN(0); @@ -760,7 +754,7 @@ void Query_cache_query::init_n_lock() { DBUG_ENTER("Query_cache_query::init_n_lock"); res=0; wri = 0; len = 0; - my_rwlock_init(&lock, NULL); + mysql_rwlock_init(key_rwlock_query_cache_query_lock, &lock); lock_writing(); DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx", (long) (((uchar*) this) - @@ -780,7 +774,7 @@ void Query_cache_query::unlock_n_destroy() active semaphore */ this->unlock_writing(); - rwlock_destroy(&lock); + mysql_rwlock_destroy(&lock); DBUG_VOID_RETURN; } @@ -1981,8 +1975,8 @@ void Query_cache::destroy() free_cache(); unlock(); - pthread_cond_destroy(&COND_cache_status_changed); - pthread_mutex_destroy(&structure_guard_mutex); + mysql_cond_destroy(&COND_cache_status_changed); + mysql_mutex_destroy(&structure_guard_mutex); initialized = 0; } DBUG_VOID_RETURN; @@ -1996,8 +1990,10 @@ void Query_cache::destroy() void Query_cache::init() { DBUG_ENTER("Query_cache::init"); - pthread_mutex_init(&structure_guard_mutex,MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_cache_status_changed, NULL); + mysql_mutex_init(key_structure_guard_mutex, + &structure_guard_mutex, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_COND_cache_status_changed, + &COND_cache_status_changed, NULL); m_cache_lock_status= Query_cache::UNLOCKED; initialized = 1; /* @@ -3843,7 +3839,7 @@ my_bool Query_cache::move_by_type(uchar **border, } while ( result_block != first_result_block ); } Query_cache_query *new_query= ((Query_cache_query *) new_block->data()); - my_rwlock_init(&new_query->lock, NULL); + mysql_rwlock_init(key_rwlock_query_cache_query_lock, &new_query->lock); /* If someone is writing to this block, inform the writer that the block |