From 651f61fc1f4172bd5f76d1060e32df76f9f76d3a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 4 Aug 2008 20:01:11 +0200 Subject: 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. --- mysys/waiting_threads.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mysys/waiting_threads.c') 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) { -- cgit v1.2.1