summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mysql.com>2008-08-04 20:01:11 +0200
committerSergei Golubchik <serg@mysql.com>2008-08-04 20:01:11 +0200
commit651f61fc1f4172bd5f76d1060e32df76f9f76d3a (patch)
treea678f0223c0ab9e94ca5c9a67ce4777d2dbfe787
parent834729048221eadb8be8dcf7929daffc26516271 (diff)
downloadmariadb-git-651f61fc1f4172bd5f76d1060e32df76f9f76d3a.tar.gz
wt_thd_cond_timedwait() now allows the list of blockers to change after
wt_thd_will_wait_for() was called. That is a caller doesn't need to hold a mutex all the time preventing blockers from releasing a resource.
-rw-r--r--mysys/waiting_threads.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index 4d375fdc899..1c87886f405 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -540,7 +540,7 @@ retry:
*/
int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
{
- int ret= WT_OK;
+ int ret= WT_TIMEOUT;
struct timespec timeout;
ulonglong before, after, starttime;
WT_RESOURCE *rc= thd->waiting_for;
@@ -565,8 +565,13 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
GetSystemTimeAsFileTime((PFILETIME)&starttime);
#endif
+ rc_wrlock(rc);
+ if (rc->owners.elements == 0 && thd->killed)
+ ret= WT_OK;
+ rc_unlock(rc);
+
set_timespec_time_nsec(timeout, starttime, wt_timeout_short*1000);
- if (!thd->killed)
+ if (ret == WT_TIMEOUT)
ret= pthread_cond_timedwait(&rc->cond, mutex, &timeout);
if (ret == WT_TIMEOUT)
{