summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authormonty@mysql.com/narttu.mysql.fi <>2007-02-23 13:13:55 +0200
committermonty@mysql.com/narttu.mysql.fi <>2007-02-23 13:13:55 +0200
commitf0ae3ce9b97f45b717201764c6af6e4bd4176e5c (patch)
treeaa523ca58b5c098a79faefb22302aa717f4ae942 /mysys
parenta5051aa4ebaf48fae5f7b6f52889c3c66a12dd23 (diff)
downloadmariadb-git-f0ae3ce9b97f45b717201764c6af6e4bd4176e5c.tar.gz
Fixed compiler warnings
Fixed compile-pentium64 scripts Fixed wrong estimate of update_with_key_prefix in sql-bench Merge bk-internal.mysql.com:/home/bk/mysql-5.1 into mysql.com:/home/my/mysql-5.1 Fixed unsafe define of uint4korr() Fixed that --extern works with mysql-test-run.pl Small trivial cleanups This also fixes a bug in counting number of rows that are updated when we have many simultanous queries Move all connection handling and command exectuion main loop from sql_parse.cc to sql_connection.cc Split handle_one_connection() into reusable sub functions. Split create_new_thread() into reusable sub functions. Added thread_scheduler; Preliminary interface code for future thread_handling code. Use 'my_thread_id' for internal thread id's Make thr_alarm_kill() to depend on thread_id instead of thread Make thr_abort_locks_for_thread() depend on thread_id instead of thread In store_globals(), set my_thread_var->id to be thd->thread_id. Use my_thread_var->id as basis for my_thread_name() The above changes makes the connection we have between THD and threads more soft. Added a lot of DBUG_PRINT() and DBUG_ASSERT() functions Fixed compiler warnings Fixed core dumps when running with --debug Removed setting of signal masks (was never used) Made event code call pthread_exit() (portability fix) Fixed that event code doesn't call DBUG_xxx functions before my_thread_init() is called. Made handling of thread_id and thd->variables.pseudo_thread_id uniform. Removed one common 'not freed memory' warning from mysqltest Fixed a couple of usage of not initialized warnings (unlikely cases) Suppress compiler warnings from bdb and (for the moment) warnings from ndb
Diffstat (limited to 'mysys')
-rw-r--r--mysys/base64.c4
-rw-r--r--mysys/mf_keycache.c5
-rw-r--r--mysys/my_getopt.c3
-rw-r--r--mysys/my_init.c18
-rw-r--r--mysys/my_thr_init.c81
-rw-r--r--mysys/ptr_cmp.c2
-rw-r--r--mysys/thr_alarm.c11
-rw-r--r--mysys/thr_alarm.c.rej220
-rw-r--r--mysys/thr_lock.c29
-rw-r--r--mysys/thr_mutex.c4
10 files changed, 91 insertions, 286 deletions
diff --git a/mysys/base64.c b/mysys/base64.c
index 9354256f667..dbe8927290d 100644
--- a/mysys/base64.c
+++ b/mysys/base64.c
@@ -100,10 +100,10 @@ base64_encode(const void *src, size_t src_len, char *dst)
}
-static inline unsigned
+static inline uint
pos(unsigned char c)
{
- return strchr(base64_table, c) - base64_table;
+ return (uint) (strchr(base64_table, c) - base64_table);
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index df76ce2ec2f..86394fec239 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -159,8 +159,10 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue,
struct st_my_thread_var *thread);
#endif
static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block);
+#ifndef DBUG_OFF
static void test_key_cache(KEY_CACHE *keycache,
const char *where, my_bool lock);
+#endif
#define KEYCACHE_HASH(f, pos) \
(((ulong) ((pos) >> keycache->key_cache_shift)+ \
@@ -2608,7 +2610,8 @@ static int flush_all_key_blocks(KEY_CACHE *keycache)
0 on success (always because it can't fail)
*/
-int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache)
+int reset_key_cache_counters(const char *name __attribute__((unused)),
+ KEY_CACHE *key_cache)
{
DBUG_ENTER("reset_key_cache_counters");
if (!key_cache->key_cache_inited)
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index c7bd2dd0a0c..aa470282aa4 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -194,6 +194,7 @@ int handle_options(int *argc, char ***argv,
Find first the right option. Return error in case of an ambiguous,
or unknown option
*/
+ LINT_INIT(prev_found);
optp= longopts;
if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
{
@@ -960,7 +961,7 @@ void my_print_variables(const struct my_option *options)
printf("%d\n", *((uint*) value));
break;
case GET_LONG:
- printf("%lu\n", *((long*) value));
+ printf("%ld\n", *((long*) value));
break;
case GET_ULONG:
printf("%lu\n", *((ulong*) value));
diff --git a/mysys/my_init.c b/mysys/my_init.c
index a553d13eaa0..7784c09d9d6 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -199,7 +199,9 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
}
if (!(infoflag & MY_DONT_FREE_DBUG))
+ {
DBUG_END(); /* Must be done before my_thread_end */
+ }
#ifdef THREAD
my_thread_end();
my_thread_global_end();
@@ -248,14 +250,16 @@ void setEnvString(char *ret, const char *name, const char *value)
}
/*
- my_paramter_handler
- Invalid paramter handler we will use instead of the one "baked" into the CRT
- for MSC v8. This one just prints out what invalid parameter was encountered.
- By providing this routine, routines like lseek will return -1 when we expect them
- to instead of crash.
+ my_parameter_handler
+
+ Invalid parameter handler we will use instead of the one "baked"
+ into the CRT for MSC v8. This one just prints out what invalid
+ parameter was encountered. By providing this routine, routines like
+ lseek will return -1 when we expect them to instead of crash.
*/
-void my_parameter_handler(const wchar_t * expression, const wchar_t * function,
- const wchar_t * file, unsigned int line,
+
+void my_parameter_handler(const wchar_t * expression, const wchar_t * function,
+ const wchar_t * file, unsigned int line,
uintptr_t pReserved)
{
DBUG_PRINT("my",("Expression: %s function: %s file: %s, line: %d",
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 853a2761224..61e6e640027 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -46,23 +46,23 @@ pthread_mutexattr_t my_fast_mutexattr;
pthread_mutexattr_t my_errorcheck_mutexattr;
#endif
-#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */
+#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */
/*
- Dummy thread spawned in my_thread_global_init() below to avoid
- race conditions in NPTL pthread_exit code.
+ Dummy thread spawned in my_thread_global_init() below to avoid
+ race conditions in NPTL pthread_exit code.
*/
-static
-pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
+static pthread_handler_t
+nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
{
/* Do nothing! */
pthread_exit(0);
return 0;
}
-
#endif
+
/*
initialize thread environment
@@ -83,25 +83,28 @@ my_bool my_thread_global_init(void)
}
#ifdef NPTL_PTHREAD_EXIT_BUG
+ /*
+ BUG#24507: Race conditions inside current NPTL pthread_exit()
+ implementation.
-/*
- BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
-
- To avoid a possible segmentation fault during concurrent executions of
- pthread_exit(), a dummy thread is spawned which initializes internal variables
- of pthread lib. See bug description for thoroughfull explanation.
+ To avoid a possible segmentation fault during concurrent
+ executions of pthread_exit(), a dummy thread is spawned which
+ initializes internal variables of pthread lib. See bug description
+ for a full explanation.
- TODO: Remove this code when fixed versions of glibc6 are in common use.
-*/
-
- pthread_t dummy_thread;
- pthread_attr_t dummy_thread_attr;
-
- pthread_attr_init(&dummy_thread_attr);
- pthread_attr_setdetachstate(&dummy_thread_attr,PTHREAD_CREATE_DETACHED);
+ TODO: Remove this code when fixed versions of glibc6 are in common
+ use.
+ */
+ {
+ pthread_t dummy_thread;
+ pthread_attr_t dummy_thread_attr;
- pthread_create(&dummy_thread,&dummy_thread_attr,nptl_pthread_exit_hack_handler,NULL);
+ pthread_attr_init(&dummy_thread_attr);
+ pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_DETACHED);
+ pthread_create(&dummy_thread,&dummy_thread_attr,
+ nptl_pthread_exit_hack_handler, NULL);
+ }
#endif
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
@@ -206,7 +209,7 @@ void my_thread_global_end(void)
#endif
}
-static long thread_id=0;
+static my_thread_id thread_id= 0;
/*
Allocate thread specific memory for the thread, used by mysys and dbug
@@ -234,15 +237,16 @@ my_bool my_thread_init(void)
my_bool error=0;
#ifdef EXTRA_DEBUG_THREADS
- fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self());
+ fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n",
+ (ulong) pthread_self());
#endif
#if !defined(__WIN__) || defined(USE_TLS)
if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys))
{
#ifdef EXTRA_DEBUG_THREADS
- fprintf(stderr,"my_thread_init() called more than once in thread %ld\n",
- pthread_self());
+ fprintf(stderr,"my_thread_init() called more than once in thread 0x%lx\n",
+ (long) pthread_self());
#endif
goto end;
}
@@ -262,7 +266,9 @@ my_bool my_thread_init(void)
tmp= &THR_KEY_mysys;
#endif
#if defined(__WIN__) && defined(EMBEDDED_LIBRARY)
- tmp->thread_self= (pthread_t)getpid();
+ tmp->pthread_self= (pthread_t) getpid();
+#else
+ tmp->pthread_self= pthread_self();
#endif
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
pthread_cond_init(&tmp->suspend, NULL);
@@ -272,6 +278,11 @@ my_bool my_thread_init(void)
tmp->id= ++thread_id;
++THR_thread_count;
pthread_mutex_unlock(&THR_LOCK_threads);
+#ifndef DBUG_OFF
+ /* Generate unique name for thread */
+ (void) my_thread_name();
+#endif
+
end:
return error;
}
@@ -295,8 +306,8 @@ void my_thread_end(void)
tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
#ifdef EXTRA_DEBUG_THREADS
- fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n",
- (long) tmp, pthread_self());
+ fprintf(stderr,"my_thread_end(): tmp: 0x%lx pthread_self: 0x%lx thread_id: %ld\n",
+ (long) tmp, (long) pthread_self(), tmp ? (long) tmp->id : 0L);
#endif
if (tmp && tmp->init)
{
@@ -357,17 +368,9 @@ struct st_my_thread_var *_my_thread_var(void)
Get name of current thread.
****************************************************************************/
-#define UNKNOWN_THREAD -1
-
-long my_thread_id()
+my_thread_id my_thread_dbug_id()
{
-#if defined(HAVE_PTHREAD_GETSEQUENCE_NP)
- return pthread_getsequence_np(pthread_self());
-#elif (defined(__sun) || defined(__sgi) || defined(__linux__))
- return pthread_self();
-#else
return my_thread_var->id;
-#endif
}
#ifdef DBUG_OFF
@@ -384,8 +387,8 @@ const char *my_thread_name(void)
struct st_my_thread_var *tmp=my_thread_var;
if (!tmp->name[0])
{
- long id=my_thread_id();
- sprintf(name_buff,"T@%ld", id);
+ my_thread_id id= my_thread_dbug_id();
+ sprintf(name_buff,"T@%lu", (ulong) id);
strmake(tmp->name,name_buff,THREAD_NAME_SIZE);
}
return tmp->name;
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
index 96c56645e94..4fdbad58aaf 100644
--- a/mysys/ptr_cmp.c
+++ b/mysys/ptr_cmp.c
@@ -185,7 +185,7 @@ my_off_t my_get_ptr(byte *ptr, uint pack_length)
case 3: pos= (my_off_t) mi_uint3korr(ptr); break;
case 2: pos= (my_off_t) mi_uint2korr(ptr); break;
case 1: pos= (my_off_t) *(uchar*) ptr; break;
- default: DBUG_ASSERT(0);
+ default: DBUG_ASSERT(0); return 0;
}
return pos;
}
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 170ee8a1b73..3fd70790281 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -146,6 +146,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
ulong now;
sigset_t old_mask;
my_bool reschedule;
+ struct st_my_thread_var *current_my_thread_var= my_thread_var;
DBUG_ENTER("thr_alarm");
DBUG_PRINT("enter",("thread: %s sec: %d",my_thread_name(),sec));
@@ -195,7 +196,8 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
alarm_data->malloced=0;
alarm_data->expire_time=now+sec;
alarm_data->alarmed=0;
- alarm_data->thread=pthread_self();
+ alarm_data->thread= current_my_thread_var->pthread_self;
+ alarm_data->thread_id= current_my_thread_var->id;
queue_insert(&alarm_queue,(byte*) alarm_data);
/* Reschedule alarm if the current one has more than sec left */
@@ -444,7 +446,7 @@ void end_thr_alarm(my_bool free_structures)
Remove another thread from the alarm
*/
-void thr_alarm_kill(pthread_t thread_id)
+void thr_alarm_kill(my_thread_id thread_id)
{
uint i;
if (alarm_aborted)
@@ -452,8 +454,7 @@ void thr_alarm_kill(pthread_t thread_id)
pthread_mutex_lock(&LOCK_alarm);
for (i=0 ; i < alarm_queue.elements ; i++)
{
- if (pthread_equal(((ALARM*) queue_element(&alarm_queue,i))->thread,
- thread_id))
+ if (((ALARM*) queue_element(&alarm_queue,i))->thread_id == thread_id)
{
ALARM *tmp=(ALARM*) queue_remove(&alarm_queue,i);
tmp->expire_time=0;
@@ -567,7 +568,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
#else /* __WIN__ */
-void thr_alarm_kill(pthread_t thread_id)
+void thr_alarm_kill(my_thread_id thread_id)
{
/* Can't do this yet */
}
diff --git a/mysys/thr_alarm.c.rej b/mysys/thr_alarm.c.rej
deleted file mode 100644
index c991121052e..00000000000
--- a/mysys/thr_alarm.c.rej
+++ /dev/null
@@ -1,220 +0,0 @@
-***************
-*** 76,96 ****
- alarm_aborted=0;
- init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
- compare_ulong,NullS);
-! sigfillset(&full_signal_set); /* Neaded to block signals */
- pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_alarm,NULL);
-! #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
-! #if defined(HAVE_mit_thread)
-! sigset(THR_CLIENT_ALARM,thread_alarm); /* int. thread system calls */
-! #else
- {
-! struct sigaction sact;
-! sact.sa_flags = 0;
-! sact.sa_handler = thread_alarm;
-! sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
- }
-- #endif
-- #endif
- sigemptyset(&s);
- sigaddset(&s, THR_SERVER_ALARM);
- alarm_thread=pthread_self();
---- 74,89 ----
- alarm_aborted=0;
- init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
- compare_ulong,NullS);
-! sigfillset(&full_signal_set); /* Needed to block signals */
- pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
- pthread_cond_init(&COND_alarm,NULL);
-! #ifndef USE_ALARM_THREAD
-! if (thd_lib_detected != THD_LIB_LT)
-! #endif
- {
-! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
-! thread_alarm);
- }
- sigemptyset(&s);
- sigaddset(&s, THR_SERVER_ALARM);
- alarm_thread=pthread_self();
-***************
-*** 108,120 ****
- }
- #elif defined(USE_ONE_SIGNAL_HAND)
- pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
-! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
-! sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
-! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
-! #endif
- #else
- pthread_sigmask(SIG_UNBLOCK, &s, NULL);
-- sigset(THR_SERVER_ALARM,process_alarm);
- #endif
- DBUG_VOID_RETURN;
- }
---- 101,115 ----
- }
- #elif defined(USE_ONE_SIGNAL_HAND)
- pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
-! if (thd_lib_detected == THD_LIB_LT)
-! {
-! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
-! process_alarm); /* Linuxthreads */
-! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
-! }
- #else
-+ my_sigset(THR_SERVER_ALARM, process_alarm);
- pthread_sigmask(SIG_UNBLOCK, &s, NULL);
- #endif
- DBUG_VOID_RETURN;
- }
-***************
-*** 240,246 ****
- if (alarm_data->malloced)
- my_free((gptr) alarm_data,MYF(0));
- found++;
-! #ifndef DBUG_OFF
- break;
- #endif
- }
---- 235,241 ----
- if (alarm_data->malloced)
- my_free((gptr) alarm_data,MYF(0));
- found++;
-! #ifdef DBUG_OFF
- break;
- #endif
- }
-***************
-*** 249,258 ****
- if (!found)
- {
- if (*alarmed)
-! fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n",
-! (long) *alarmed, alarm_queue.elements);
-! DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
-! (long) *alarmed));
- }
- pthread_mutex_unlock(&LOCK_alarm);
- pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
---- 244,254 ----
- if (!found)
- {
- if (*alarmed)
-! fprintf(stderr,
-! "Warning: Didn't find alarm 0x%lx in queue of %d alarms\n",
-! (long) *alarmed, alarm_queue.elements);
-! DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
-! (long) *alarmed));
- }
- pthread_mutex_unlock(&LOCK_alarm);
- pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
-***************
-*** 274,291 ****
- This must be first as we can't call DBUG inside an alarm for a normal thread
- */
-
-! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
-! if (!pthread_equal(pthread_self(),alarm_thread))
- {
- #if defined(MAIN) && !defined(__bsdi__)
-! printf("thread_alarm\n"); fflush(stdout);
- #endif
- #ifdef DONT_REMEMBER_SIGNAL
-! sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
- #endif
- return;
- }
-- #endif
-
- /*
- We have to do do the handling of the alarm in a sub function,
---- 270,287 ----
- This must be first as we can't call DBUG inside an alarm for a normal thread
- */
-
-! if (thd_lib_detected == THD_LIB_LT &&
-! !pthread_equal(pthread_self(),alarm_thread))
- {
- #if defined(MAIN) && !defined(__bsdi__)
-! printf("thread_alarm in process_alarm\n"); fflush(stdout);
- #endif
- #ifdef DONT_REMEMBER_SIGNAL
-! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
-! process_alarm); /* int. thread system calls */
- #endif
- return;
- }
-
- /*
- We have to do do the handling of the alarm in a sub function,
-***************
-*** 301,307 ****
- process_alarm_part2(sig);
- #ifndef USE_ALARM_THREAD
- #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
-! sigset(THR_SERVER_ALARM,process_alarm);
- #endif
- pthread_mutex_unlock(&LOCK_alarm);
- pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
---- 297,303 ----
- process_alarm_part2(sig);
- #ifndef USE_ALARM_THREAD
- #if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
-! my_sigset(THR_SERVER_ALARM, process_alarm);
- #endif
- pthread_mutex_unlock(&LOCK_alarm);
- pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
-***************
-*** 504,520 ****
- ARGSUSED
- */
-
-- #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
- static sig_handler thread_alarm(int sig)
- {
- #ifdef MAIN
- printf("thread_alarm\n"); fflush(stdout);
- #endif
- #ifdef DONT_REMEMBER_SIGNAL
-! sigset(sig,thread_alarm); /* int. thread system calls */
- #endif
- }
-- #endif
-
-
- #ifdef HAVE_TIMESPEC_TS_SEC
---- 499,513 ----
- ARGSUSED
- */
-
- static sig_handler thread_alarm(int sig)
- {
- #ifdef MAIN
- printf("thread_alarm\n"); fflush(stdout);
- #endif
- #ifdef DONT_REMEMBER_SIGNAL
-! my_sigset(sig, thread_alarm); /* int. thread system calls */
- #endif
- }
-
-
- #ifdef HAVE_TIMESPEC_TS_SEC
-***************
-*** 915,921 ****
- printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
- fflush(stdout);
- #ifdef DONT_REMEMBER_SIGNAL
-! sigset(sig,print_signal_warning); /* int. thread system calls */
- #endif
- #ifndef OS2
- if (sig == SIGALRM)
---- 908,914 ----
- printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
- fflush(stdout);
- #ifdef DONT_REMEMBER_SIGNAL
-! my_sigset(sig, print_signal_warning); /* int. thread system calls */
- #endif
- #ifndef OS2
- if (sig == SIGALRM)
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 5ce7e99fbdc..94c34eef2fa 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -343,8 +343,9 @@ void thr_lock_delete(THR_LOCK *lock)
void thr_lock_info_init(THR_LOCK_INFO *info)
{
- info->thread= pthread_self();
- info->thread_id= my_thread_id(); /* for debugging */
+ struct st_my_thread_var *tmp= my_thread_var;
+ info->thread= tmp->pthread_self;
+ info->thread_id= tmp->id;
info->n_cursors= 0;
}
@@ -622,8 +623,10 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
statistic_increment(locks_immediate,&THR_LOCK_lock);
goto end;
}
+ /* purecov: begin inspected */
DBUG_PRINT("lock",("write locked by thread: 0x%lx",
lock->write.data->owner->info->thread_id));
+ /* purecov: end */
}
else
{
@@ -658,7 +661,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
goto end;
}
}
- DBUG_PRINT("lock",("write locked by thread: 0x%lx, type: %d",
+ DBUG_PRINT("lock",("write locked by thread: 0x%lx type: %d",
lock->read.data->owner->info->thread_id, data->type));
}
wait_queue= &lock->write_wait;
@@ -720,8 +723,10 @@ static inline void free_all_read_locks(THR_LOCK *lock,
}
lock->read_no_write_count++;
}
+ /* purecov: begin inspected */
DBUG_PRINT("lock",("giving read lock to thread: 0x%lx",
data->owner->info->thread_id));
+ /* purecov: end */
data->cond=0; /* Mark thread free */
VOID(pthread_cond_signal(cond));
} while ((data=data->next));
@@ -806,8 +811,10 @@ void thr_unlock(THR_LOCK_DATA *data)
if (data->type == TL_WRITE_CONCURRENT_INSERT &&
(*lock->check_status)(data->status_param))
data->type=TL_WRITE; /* Upgrade lock */
+ /* purecov: begin inspected */
DBUG_PRINT("lock",("giving write lock of type %d to thread: 0x%lx",
data->type, data->owner->info->thread_id));
+ /* purecov: end */
{
pthread_cond_t *cond=data->cond;
data->cond=0; /* Mark thread free */
@@ -1006,7 +1013,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count)
thr_unlock(*pos);
else
{
- DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: %ld lock: 0x%lx",
+ DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: 0x%lx lock: 0x%lx",
(long) *pos, (*pos)->owner->info->thread_id,
(long) (*pos)->lock));
}
@@ -1054,7 +1061,7 @@ void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock)
This is used to abort all locks for a specific thread
*/
-my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
+my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread_id)
{
THR_LOCK_DATA *data;
my_bool found= FALSE;
@@ -1063,7 +1070,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
pthread_mutex_lock(&lock->mutex);
for (data= lock->read_wait.data; data ; data= data->next)
{
- if (pthread_equal(thread, data->owner->info->thread))
+ if (data->owner->info->thread_id == thread_id) /* purecov: tested */
{
DBUG_PRINT("info",("Aborting read-wait lock"));
data->type= TL_UNLOCK; /* Mark killed */
@@ -1080,7 +1087,7 @@ my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
}
for (data= lock->write_wait.data; data ; data= data->next)
{
- if (pthread_equal(thread, data->owner->info->thread))
+ if (data->owner->info->thread_id == thread_id) /* purecov: tested */
{
DBUG_PRINT("info",("Aborting write-wait lock"));
data->type= TL_UNLOCK;
@@ -1133,7 +1140,9 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data,
enum thr_lock_type new_lock_type)
{
THR_LOCK *lock=in_data->lock;
+#ifndef DBUG_OFF
enum thr_lock_type old_lock_type= in_data->type;
+#endif
#ifdef TO_BE_REMOVED
THR_LOCK_DATA *data, *next;
bool start_writers= FALSE;
@@ -1528,6 +1537,10 @@ static void test_get_status(void* param __attribute__((unused)),
{
}
+static void test_update_status(void* param __attribute__((unused)))
+{
+}
+
static void test_copy_status(void* to __attribute__((unused)) ,
void *from __attribute__((unused)))
{
@@ -1620,7 +1633,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
{
thr_lock_init(locks+i);
locks[i].check_status= test_check_status;
- locks[i].update_status=test_get_status;
+ locks[i].update_status=test_update_status;
locks[i].copy_status= test_copy_status;
locks[i].get_status= test_get_status;
}
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 42f9fe5f600..007bae2accf 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -212,7 +212,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
{
fprintf(stderr,
"safe_mutex: Count was %d in thread 0x%lx when locking mutex at %s, line %d\n",
- mp->count-1, my_thread_id(), file, line);
+ mp->count-1, my_thread_dbug_id(), file, line);
fflush(stderr);
abort();
}
@@ -250,7 +250,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
{
fprintf(stderr,
"safe_mutex: Count was %d in thread 0x%lx when locking mutex at %s, line %d (error: %d (%d))\n",
- mp->count-1, my_thread_id(), file, line, error, error);
+ mp->count-1, my_thread_dbug_id(), file, line, error, error);
fflush(stderr);
abort();
}