summaryrefslogtreecommitdiff
path: root/mysys/thr_lock.c
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-08-31 23:02:09 +0300
committerunknown <monty@hundin.mysql.fi>2001-08-31 23:02:09 +0300
commit4295917682a23b6f8d493d9433b0b7c1f244c421 (patch)
treee26c23520c4a8d41f977bce9e83f52bdd4b00fc4 /mysys/thr_lock.c
parent421e64ae356a1633ea50294b48c5025ea387a64d (diff)
downloadmariadb-git-4295917682a23b6f8d493d9433b0b7c1f244c421.tar.gz
Fixed problem with INSERT DELAYED
Make killing threads safer Docs/manual.texi: Portability fix mysys/thr_lock.c: Fixed problem with INSERT DELAYED sql/mysqld.cc: Make shutdown safer sql/sql_class.cc: Make kill thread safer sql/sql_insert.cc: Make kill thread safer
Diffstat (limited to 'mysys/thr_lock.c')
-rw-r--r--mysys/thr_lock.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 7d86d0c9524..841c2f1bb91 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -115,7 +115,7 @@ my_bool init_thr_lock()
static uint found_errors=0;
static int check_lock(struct st_lock_list *list, const char* lock_type,
- const char *where, my_bool same_thread)
+ const char *where, my_bool same_thread, bool no_cond)
{
THR_LOCK_DATA *data,**prev;
uint count=0;
@@ -148,6 +148,13 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
lock_type,where);
return 1;
}
+ if (no_cond && data->cond)
+ {
+ fprintf(stderr,
+ "Warning: Found active lock with not reset cond %s: %s\n",
+ lock_type,where);
+ return 1;
+ }
prev= &data->next;
}
if (data)
@@ -172,10 +179,10 @@ static void check_locks(THR_LOCK *lock, const char *where,
uint old_found_errors=found_errors;
if (found_errors < MAX_FOUND_ERRORS)
{
- if (check_lock(&lock->write,"write",where,1) |
- check_lock(&lock->write_wait,"write_wait",where,0) |
- check_lock(&lock->read,"read",where,0) |
- check_lock(&lock->read_wait,"read_wait",where,0))
+ if (check_lock(&lock->write,"write",where,1,1) |
+ check_lock(&lock->write_wait,"write_wait",where,0,0) |
+ check_lock(&lock->read,"read",where,0,1) |
+ check_lock(&lock->read_wait,"read_wait",where,0,0))
found_errors++;
if (found_errors < MAX_FOUND_ERRORS)
@@ -326,6 +333,7 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param)
data->thread=pthread_self();
data->thread_id=my_thread_id(); /* for debugging */
data->status_param=param;
+ data->cond=0;
}
@@ -416,6 +424,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
DBUG_ENTER("thr_lock");
data->next=0;
+ data->cond=0; /* safety */
data->type=lock_type;
data->thread=pthread_self(); /* Must be reset ! */
data->thread_id=my_thread_id(); /* Must be reset ! */
@@ -977,6 +986,10 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
lock->write_wait.data=data;
check_locks(lock,"upgrading lock",0);
}
+ else
+ {
+ check_locks(lock,"waiting for lock",0);
+ }
DBUG_RETURN(wait_for_lock(&lock->write_wait,data,1));
}