Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3f3d60d

Browse files
committed
Fix race condition in ConditionVariablePrepareToSleep.
Thomas Munro
1 parent fc8219d commit 3f3d60d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/storage/lmgr/condition_variable.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ ConditionVariablePrepareToSleep(ConditionVariable *cv)
7171
&MyProc->procLatch, NULL);
7272
}
7373

74+
/*
75+
* Reset my latch before adding myself to the queue and before entering
76+
* the caller's predicate loop.
77+
*/
78+
ResetLatch(&MyProc->procLatch);
79+
7480
/* Add myself to the wait queue. */
7581
SpinLockAcquire(&cv->mutex);
7682
if (!proclist_contains(&cv->wakeup, pgprocno, cvWaitLink))
7783
proclist_push_tail(&cv->wakeup, pgprocno, cvWaitLink);
7884
SpinLockRelease(&cv->mutex);
79-
80-
/* Reset my latch before entering the caller's predicate loop. */
81-
ResetLatch(&MyProc->procLatch);
8285
}
8386

8487
/*--------------------------------------------------------------------------

0 commit comments

Comments
 (0)