diff options
author | unknown <monty@donna.mysql.com> | 2000-09-21 01:58:38 +0300 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2000-09-21 01:58:38 +0300 |
commit | 43044b685f765718f5f90ac26fa3e2317b5749e9 (patch) | |
tree | e2dd869fb38dfdf7e26817e7b0f7a7a6add22758 /mysys | |
parent | 73826420c3114dad809c2c051ba60a6e3f50ee20 (diff) | |
download | mariadb-git-43044b685f765718f5f90ac26fa3e2317b5749e9.tar.gz |
Fix for SAFE_MUTEX + MERGE tables
Docs/manual.texi:
Fix for release
include/my_pthread.h:
Fix for SAFE_MUTEX for windows
include/myisammrg.h:
Fix for empty MERGE tables
myisam/ft_stopwords.c:
Free used memory
myisammrg/myrg_open.c:
Fix for empty MERGE tables
myisammrg/myrg_queue.c:
Fix for empty MERGE tables
myisammrg/myrg_rfirst.c:
cleanup
myisammrg/myrg_rkey.c:
cleanup
mysys/my_thr_init.c:
Fix SAFE_MUTEX for windows
mysys/my_winthread.c:
Fix SAFE_MUTEX for windows
mysys/thr_mutex.c:
Fix SAFE_MUTEX for windows
sql/ha_myisammrg.cc:
Fix for empty MERGE tables
sql/mysqld.cc:
Fix type
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_thr_init.c | 7 | ||||
-rw-r--r-- | mysys/my_winthread.c | 10 | ||||
-rw-r--r-- | mysys/thr_mutex.c | 14 |
3 files changed, 25 insertions, 6 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 6b75444f3fc..f24c8393ba9 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -35,9 +35,6 @@ pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, #ifndef HAVE_LOCALTIME_R pthread_mutex_t LOCK_localtime_r; #endif -#ifdef __WIN__ -pthread_mutex_t THR_LOCK_thread; -#endif /* FIXME Note. TlsAlloc does not set an auto destructor, so the function my_thread_global_free must be called from @@ -60,7 +57,7 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_net,NULL); pthread_mutex_init(&THR_LOCK_charset,NULL); #ifdef __WIN__ - pthread_mutex_init(&THR_LOCK_thread,NULL); + win_pthread_init(); #endif #ifndef HAVE_LOCALTIME_R pthread_mutex_init(&LOCK_localtime_r,NULL); @@ -78,7 +75,7 @@ void my_thread_global_end(void) static long thread_id=0; /* - We can't use mutex_locks here if we re using windows as + We can't use mutex_locks here if we are using windows as we may have compiled the program with SAFE_MUTEX, in which case the checking of mutex_locks will not work until the pthread_self thread specific variable is initialized. diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index e410121af98..6a99fa0bb02 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -19,13 +19,16 @@ ** Simulation of posix threads calls for WIN95 and NT *****************************************************************************/ +/* SAFE_MUTEX will not work until the thread structure is up to date */ +#undef SAFE_MUTEX + #include "mysys_priv.h" #if defined(THREAD) && defined(__WIN__) #include <m_string.h> #undef getpid #include <process.h> -extern pthread_mutex_t THR_LOCK_thread; +static pthread_mutex_t THR_LOCK_thread; struct pthread_map { @@ -34,6 +37,11 @@ struct pthread_map void *param; }; +void win_pthread_init(void) +{ + pthread_mutex_init(&THR_LOCK_thread,NULL); +} + /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 73d1d24d9a4..149a30a4b24 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -67,6 +67,7 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) { fprintf(stderr,"safe_mutex: Trying to lock mutex at %s, line %d, when the mutex was already locked at %s, line %d\n", file,line,mp->file,mp->line); + fflush(stderr); abort(); } pthread_mutex_unlock(&mp->global); @@ -75,11 +76,13 @@ int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) { fprintf(stderr,"Got error %d when trying to lock mutex at %s, line %d\n", error, file, line); + fflush(stderr); abort(); } if (mp->count++) { fprintf(stderr,"safe_mutex: Error in thread libray: Got mutex at %s, line %d more than 1 time\n", file,line); + fflush(stderr); abort(); } mp->thread=pthread_self(); @@ -98,12 +101,14 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) { fprintf(stderr,"safe_mutex: Trying to unlock mutex that wasn't locked at %s, line %d\n Last used at %s, line: %d\n", file,line,mp->file ? mp->file : "",mp->line); + fflush(stderr); abort(); } if (!pthread_equal(pthread_self(),mp->thread)) { fprintf(stderr,"safe_mutex: Trying to unlock mutex at %s, line %d that was locked by another thread at: %s, line: %d\n", file,line,mp->file,mp->line); + fflush(stderr); abort(); } mp->count--; @@ -115,6 +120,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) if (error) { fprintf(stderr,"safe_mutex: Got error: %d when trying to unlock mutex at %s, line %d\n", error, file, line); + fflush(stderr); abort(); } #endif /* __WIN__ */ @@ -131,12 +137,14 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, if (mp->count == 0) { fprintf(stderr,"safe_mutex: Trying to cond_wait on a unlocked mutex at %s, line %d\n",file,line); + fflush(stderr); abort(); } if (!pthread_equal(pthread_self(),mp->thread)) { fprintf(stderr,"safe_mutex: Trying to cond_wait on a mutex at %s, line %d that was locked by another thread at: %s, line: %d\n", file,line,mp->file,mp->line); + fflush(stderr); abort(); } @@ -144,6 +152,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, { fprintf(stderr,"safe_mutex: Count was %d on locked mutex at %s, line %d\n", mp->count+1, file, line); + fflush(stderr); abort(); } pthread_mutex_unlock(&mp->global); @@ -152,6 +161,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, if (error) { fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_wait at %s, line %d\n", error, file, line); + fflush(stderr); abort(); } if (mp->count++) @@ -159,6 +169,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 %lx when locking mutex at %s, line %d\n", mp->count-1, my_thread_id(), file, line); + fflush(stderr); abort(); } mp->thread=pthread_self(); @@ -178,6 +189,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, if (mp->count != 1 || !pthread_equal(pthread_self(),mp->thread)) { fprintf(stderr,"safe_mutex: Trying to cond_wait at %s, line %d on a not hold mutex\n",file,line); + fflush(stderr); abort(); } mp->count--; /* Mutex will be released */ @@ -195,6 +207,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, fprintf(stderr, "safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d)\n", mp->count-1, my_thread_id(), file, line, error); + fflush(stderr); abort(); } mp->thread=pthread_self(); @@ -211,6 +224,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) { fprintf(stderr,"safe_mutex: Trying to destroy a mutex that was locked at %s, line %d at %s, line %d\n", mp->file,mp->line, file, line); + fflush(stderr); abort(); } #ifdef __WIN__ |