diff options
author | deischen <deischen@FreeBSD.org> | 2006-02-23 21:34:08 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2006-02-23 21:34:08 +0000 |
commit | 4dd473489ef973f5d3a1b52dd87370ef00097810 (patch) | |
tree | 8d8078ef7abffc1a5ffc129a3fdf7c191a662be1 /lib/libpthread/thread/thr_cond.c | |
parent | 2460d0002143524f8e136a911d7eece91b451d90 (diff) | |
download | FreeBSD-src-4dd473489ef973f5d3a1b52dd87370ef00097810.zip FreeBSD-src-4dd473489ef973f5d3a1b52dd87370ef00097810.tar.gz |
Eliminate a race condition in timed waits (cv, mutex, and sleeps).
MFC Candidate.
PR: 93592
Diffstat (limited to 'lib/libpthread/thread/thr_cond.c')
-rw-r--r-- | lib/libpthread/thread/thr_cond.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c index cd719d4..a50a690 100644 --- a/lib/libpthread/thread/thr_cond.c +++ b/lib/libpthread/thread/thr_cond.c @@ -421,11 +421,6 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* Return invalid argument error: */ rval = EINVAL; } else { - /* Set the wakeup time: */ - curthread->wakeup_time.tv_sec = abstime->tv_sec; - curthread->wakeup_time.tv_nsec = - abstime->tv_nsec; - /* Reset the timeout and interrupted flags: */ curthread->timeout = 0; curthread->interrupted = 0; @@ -464,6 +459,11 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, * set the state. */ THR_SCHED_LOCK(curthread, curthread); + /* Set the wakeup time: */ + curthread->wakeup_time.tv_sec = + abstime->tv_sec; + curthread->wakeup_time.tv_nsec = + abstime->tv_nsec; THR_SET_STATE(curthread, PS_COND_WAIT); /* Remember the CV: */ |