mirror of
https://github.com/postgres/postgres.git
synced 2025-10-18 04:29:09 +03:00
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.
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user