summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-02-14 11:34:46 +0100
committerunknown <msvensson@neptunus.(none)>2006-02-14 11:34:46 +0100
commit6b2d7326f2e56aacf676b1b28215d25779b04600 (patch)
treeff27b986dfb45c37f6861c9179811459107c7816 /mysys
parent4e8f2a12bc0145224af14138aee964902b88648e (diff)
downloadmariadb-git-6b2d7326f2e56aacf676b1b28215d25779b04600.tar.gz
Bug#16333 Assertion failure in lock.cc in the sysbench test
- Set the value of mp->thread before mp->count to avoid race condition. mysys/thr_mutex.c: Set mp->thread before mp->count is changed. Since mp->count is used in the macros 'safe_mutex_assert_not_owner' and 'safe_mutex_assert_owner' as an inidicator wheter to look at the mp->thread variable or not. This means that when mp->count is changed, the mp->thread should akready be set to the owning thread. Also set mp->thread to 0 when unlocking the mutex.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/thr_mutex.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 3326068d164..1791bb6e4c4 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -103,7 +103,7 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
fflush(stderr);
abort();
}
-
+
pthread_mutex_lock(&mp->global);
if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread))
{
@@ -121,6 +121,7 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
fflush(stderr);
abort();
}
+ mp->thread= pthread_self();
if (mp->count++)
{
fprintf(stderr,"safe_mutex: Error in thread libray: Got mutex at %s, \
@@ -128,7 +129,6 @@ line %d more than 1 time\n", file,line);
fflush(stderr);
abort();
}
- mp->thread=pthread_self();
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
@@ -154,6 +154,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
fflush(stderr);
abort();
}
+ mp->thread= 0;
mp->count--;
#ifdef __WIN__
pthread_mutex_unlock(&mp->mutex);
@@ -207,6 +208,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
fflush(stderr);
abort();
}
+ mp->thread=pthread_self();
if (mp->count++)
{
fprintf(stderr,
@@ -215,7 +217,6 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
fflush(stderr);
abort();
}
- mp->thread=pthread_self();
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);
@@ -245,6 +246,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
}
#endif
pthread_mutex_lock(&mp->global);
+ mp->thread=pthread_self();
if (mp->count++)
{
fprintf(stderr,
@@ -253,7 +255,6 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
fflush(stderr);
abort();
}
- mp->thread=pthread_self();
mp->file= file;
mp->line=line;
pthread_mutex_unlock(&mp->global);