aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-02-09 14:42:32 -0500
committerRobert Haas <rhaas@postgresql.org>2017-02-09 14:42:32 -0500
commit3f3d60d3bbd10f6cc118d24aadc60e96b9854576 (patch)
treef08f6bfcb459567e0dbf9b79716fcf1575876ad6 /src
parentfc8219dc54c95ea673560b786aa8123ce6ec5977 (diff)
downloadpostgresql-3f3d60d3bbd10f6cc118d24aadc60e96b9854576.tar.gz
postgresql-3f3d60d3bbd10f6cc118d24aadc60e96b9854576.zip
Fix race condition in ConditionVariablePrepareToSleep.
Thomas Munro
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/lmgr/condition_variable.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/storage/lmgr/condition_variable.c b/src/backend/storage/lmgr/condition_variable.c
index 67fe177a7dd..6f1ef0b7e55 100644
--- a/src/backend/storage/lmgr/condition_variable.c
+++ b/src/backend/storage/lmgr/condition_variable.c
@@ -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);
}
/*--------------------------------------------------------------------------