Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1981 05/08/16 11:39:57 jimw@stripped +1 -0
Fix SLEEP() to be interruptable, and remove support for sub-second
resolution. (Bug #12582)
sql/item_func.cc
1.241 05/08/16 11:39:53 jimw@stripped +23 -3
Use pthread_cond_timedwait() for SLEEP() so that it can be killed
using the normal thread/query-killing code. This also removes support
for sub-second SLEEP() resolution, since that is non-portable.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jimw
# Host: rama.(none)
# Root: /home/jimw/my/mysql-5.0-12582
--- 1.240/sql/item_func.cc 2005-08-15 08:15:03 -07:00
+++ 1.241/sql/item_func.cc 2005-08-16 11:39:53 -07:00
@@ -3266,10 +3266,30 @@
longlong Item_func_sleep::val_int()
{
+ THD *thd= current_thd;
+ struct timespec abstime;
+ pthread_cond_t cond;
+
DBUG_ASSERT(fixed == 1);
- double time= args[0]->val_real();
- my_sleep((ulong)time*1000000L);
- return 0;
+
+ longlong time= args[0]->val_int();
+ set_timespec(abstime, (ulong)time);
+
+ pthread_cond_init(&cond, NULL);
+ pthread_mutex_lock(&LOCK_user_locks);
+ thd->mysys_var->current_mutex= &LOCK_user_locks;
+ thd->mysys_var->current_cond= &cond;
+
+ while (!thd->killed &&
+ pthread_cond_timedwait(&cond, &LOCK_user_locks,
+ &abstime) != ETIMEDOUT) ;
+
+ thd->mysys_var->current_mutex= 0;
+ thd->mysys_var->current_cond= 0;
+ pthread_mutex_unlock(&LOCK_user_locks);
+ pthread_cond_destroy(&cond);
+
+ return thd->killed ? 1 : 0;
}
| Thread |
|---|
| • bk commit into 5.0 tree (jimw:1.1981) BUG#12582 | Jim Winstead | 16 Aug |