diff options
author | Alexander Nozdrin <alik@sun.com> | 2009-10-14 12:25:39 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2009-10-14 12:25:39 +0400 |
commit | c30d924dd5485f24818264d8e533820bcf1bcba0 (patch) | |
tree | 1b3260f72106f50b182546dff41127a389144fa1 /mysys | |
parent | 829525756e7a769b0c0de716f6207f5f21daa994 (diff) | |
parent | 310833ff2e6a3c1e3ef397e78605661eee430198 (diff) | |
download | mariadb-git-c30d924dd5485f24818264d8e533820bcf1bcba0.tar.gz |
Manual merge from mysql-trunk-merge.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/hash.c | 9 | ||||
-rw-r--r-- | mysys/my_largepage.c | 2 | ||||
-rw-r--r-- | mysys/my_static.c | 8 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 7 | ||||
-rw-r--r-- | mysys/my_wincond.c | 3 | ||||
-rw-r--r-- | mysys/thr_lock.c | 22 |
6 files changed, 38 insertions, 13 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index 63933abb085..9c1957bf0aa 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -332,13 +332,8 @@ my_bool my_hash_insert(HASH *info, const uchar *record) { int flag; size_t idx,halfbuff,hash_nr,first_index; - uchar *ptr_to_rec,*ptr_to_rec2; - HASH_LINK *data,*empty,*gpos,*gpos2,*pos; - - LINT_INIT(gpos); - LINT_INIT(gpos2); - LINT_INIT(ptr_to_rec); - LINT_INIT(ptr_to_rec2); + uchar *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2); + HASH_LINK *data,*empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos; if (HASH_UNIQUE & info->flags) { diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index a20111396cb..b50a606c8d8 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -121,7 +121,7 @@ uchar* my_large_malloc_int(size_t size, myf my_flags) DBUG_ENTER("my_large_malloc_int"); /* Align block size to my_large_page_size */ - size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size; + size= MY_ALIGN(size, (size_t) my_large_page_size); shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W); if (shmid < 0) diff --git a/mysys/my_static.c b/mysys/my_static.c index 14f04491430..62e6d402315 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -92,6 +92,14 @@ void (*error_handler_hook)(uint error,const char *str,myf MyFlags)= void (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= my_message_no_curses; +#if defined(ENABLED_DEBUG_SYNC) +/** + Global pointer to be set if callback function is defined + (e.g. in mysqld). See sql/debug_sync.cc. +*/ +void (*debug_sync_C_callback_ptr)(const char *, size_t); +#endif /* defined(ENABLED_DEBUG_SYNC) */ + #ifdef __WIN__ /* from my_getsystime.c */ ulonglong query_performance_frequency, query_performance_offset; diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index c6057f19a82..f37ba111993 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -106,10 +106,11 @@ my_bool my_thread_global_init(void) pthread_attr_t dummy_thread_attr; pthread_attr_init(&dummy_thread_attr); - pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_JOINABLE); - pthread_create(&dummy_thread,&dummy_thread_attr, - nptl_pthread_exit_hack_handler, NULL); + if (pthread_create(&dummy_thread,&dummy_thread_attr, + nptl_pthread_exit_hack_handler, NULL) == 0) + (void)pthread_join(dummy_thread, NULL); } #endif /* TARGET_OS_LINUX */ diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 956d29a970b..e7d8073a163 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -119,13 +119,12 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, LeaveCriticalSection(&cond->lock_waiting); LeaveCriticalSection(mutex); - result= WaitForMultipleObjects(2, cond->events, FALSE, timeout); EnterCriticalSection(&cond->lock_waiting); cond->waiting--; - if (cond->waiting == 0 && result == (WAIT_OBJECT_0+BROADCAST)) + if (cond->waiting == 0) { /* We're the last waiter to be notified or to stop waiting, so diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 31638ecee9a..0e0e93cf220 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -398,6 +398,28 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, my_bool can_deadlock= test(data->owner->info->n_cursors); DBUG_ENTER("wait_for_lock"); + /* + One can use this to signal when a thread is going to wait for a lock. + See debug_sync.cc. + + Beware of waiting for a signal here. The lock has aquired its mutex. + While waiting on a signal here, the locking thread could not aquire + the mutex to release the lock. One could lock up the table + completely. + + In detail it works so: When thr_lock() tries to acquire a table + lock, it locks the lock->mutex, checks if it can have the lock, and + if not, it calls wait_for_lock(). Here it unlocks the table lock + while waiting on a condition. The sync point is located before this + wait for condition. If we have a waiting action here, we hold the + the table locks mutex all the time. Any attempt to look at the table + lock by another thread blocks it immediately on lock->mutex. This + can easily become an unexpected and unobvious blockage. So be + warned: Do not request a WAIT_FOR action for the 'wait_for_lock' + sync point unless you really know what you do. + */ + DEBUG_SYNC_C("wait_for_lock"); + if (!in_wait_list) { (*wait->last)=data; /* Wait for lock */ |