diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-05-10 14:34:22 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-05-10 14:34:53 -0400 |
commit | f40022f1adaeff85b01d98fea38cf5aa16814aa7 (patch) | |
tree | 3a5337271306c5df48a23df0e8abc6729c771e92 /src/backend/port/win32_latch.c | |
parent | 586d356bc5af1aa61f965f6ba1cbeb1533ec8c99 (diff) |
Make WaitLatch's WL_POSTMASTER_DEATH result trustworthy; simplify callers.
Per a suggestion from Peter Geoghegan, make WaitLatch responsible for
verifying that the WL_POSTMASTER_DEATH bit it returns is truthful (by
testing PostmasterIsAlive). Then simplify its callers, who no longer
need to do that for themselves. Remove weasel wording about falsely-set
result bits from WaitLatch's API contract.
Diffstat (limited to 'src/backend/port/win32_latch.c')
-rw-r--r-- | src/backend/port/win32_latch.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/port/win32_latch.c b/src/backend/port/win32_latch.c index e4fe05fa4b6..622798924dc 100644 --- a/src/backend/port/win32_latch.c +++ b/src/backend/port/win32_latch.c @@ -26,6 +26,7 @@ #include "miscadmin.h" #include "postmaster/postmaster.h" #include "storage/latch.h" +#include "storage/pmsignal.h" #include "storage/shmem.h" @@ -217,8 +218,15 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock, else if ((wakeEvents & WL_POSTMASTER_DEATH) && rc == WAIT_OBJECT_0 + pmdeath_eventno) { - /* Postmaster died */ - result |= WL_POSTMASTER_DEATH; + /* + * Postmaster apparently died. Since the consequences of falsely + * returning WL_POSTMASTER_DEATH could be pretty unpleasant, we + * take the trouble to positively verify this with + * PostmasterIsAlive(), even though there is no known reason to + * think that the event could be falsely set on Windows. + */ + if (!PostmasterIsAlive()) + result |= WL_POSTMASTER_DEATH; } else elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %lu", rc); |