mirror of
https://github.com/postgres/postgres.git
synced 2026-04-15 22:10:45 -04:00
Fix race condition in ConditionVariablePrepareToSleep.
Thomas Munro
This commit is contained in:
parent
fc8219dc54
commit
3f3d60d3bb
1 changed files with 6 additions and 3 deletions
|
|
@ -71,14 +71,17 @@ ConditionVariablePrepareToSleep(ConditionVariable *cv)
|
|||
&MyProc->procLatch, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset my latch before adding myself to the queue and before entering
|
||||
* the caller's predicate loop.
|
||||
*/
|
||||
ResetLatch(&MyProc->procLatch);
|
||||
|
||||
/* Add myself to the wait queue. */
|
||||
SpinLockAcquire(&cv->mutex);
|
||||
if (!proclist_contains(&cv->wakeup, pgprocno, cvWaitLink))
|
||||
proclist_push_tail(&cv->wakeup, pgprocno, cvWaitLink);
|
||||
SpinLockRelease(&cv->mutex);
|
||||
|
||||
/* Reset my latch before entering the caller's predicate loop. */
|
||||
ResetLatch(&MyProc->procLatch);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue