summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@sun.com>2009-10-13 13:42:38 +0400
committerAlexander Nozdrin <alik@sun.com>2009-10-13 13:42:38 +0400
commitc69629d269fcab948800a427eff587b68cd7cf34 (patch)
treee56ffd06670e5f719dc7c91ca477eb50aa578a24 /mysys
parenteddd727a3a3de0e27e921551263e18c0b558a8ca (diff)
parent85bb4aa09ee906c5cb8a3f7af8ff319e3a6c93b9 (diff)
downloadmariadb-git-c69629d269fcab948800a427eff587b68cd7cf34.tar.gz
Merge from mysql-5.1.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/Makefile.am12
-rw-r--r--mysys/hash.c9
-rw-r--r--mysys/my_largepage.c2
-rw-r--r--mysys/my_static.c8
-rw-r--r--mysys/my_thr_init.c7
-rw-r--r--mysys/thr_lock.c22
6 files changed, 47 insertions, 13 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 4b07cf89676..aedd11dc824 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2000-2006 MySQL AB
+# Copyright (C) 2000-2006 MySQL AB, 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
@@ -25,7 +25,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \
- mf_keycache.c mf_keycaches.c my_crc32.c \
+ mf_keycaches.c my_crc32.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \
@@ -53,6 +53,14 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \
my_windac.c my_access.c base64.c my_libwrap.c
+
+if NEED_THREAD
+# mf_keycache is used only in the server, so it is safe to leave the file
+# out of the non-threaded library.
+# In fact, it will currently not compile without thread support.
+libmysys_a_SOURCES += mf_keycache.c
+endif
+
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \
CMakeLists.txt mf_soundex.c \
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 d0c20da828a..a21a3d11104 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -92,6 +92,14 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
int (*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 2278c467f32..d8c7d85ff30 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -108,10 +108,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/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 */