Commit 651f61fc authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent 83472904
...@@ -540,7 +540,7 @@ retry: ...@@ -540,7 +540,7 @@ retry:
*/ */
int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex) int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
{ {
int ret= WT_OK; int ret= WT_TIMEOUT;
struct timespec timeout; struct timespec timeout;
ulonglong before, after, starttime; ulonglong before, after, starttime;
WT_RESOURCE *rc= thd->waiting_for; WT_RESOURCE *rc= thd->waiting_for;
...@@ -565,8 +565,13 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex) ...@@ -565,8 +565,13 @@ int wt_thd_cond_timedwait(WT_THD *thd, pthread_mutex_t *mutex)
GetSystemTimeAsFileTime((PFILETIME)&starttime); GetSystemTimeAsFileTime((PFILETIME)&starttime);
#endif #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); 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); ret= pthread_cond_timedwait(&rc->cond, mutex, &timeout);
if (ret == WT_TIMEOUT) if (ret == WT_TIMEOUT)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment