/*
* Emergency bailout if postmaster has died. This is to avoid the
- * necessity for manual cleanup of all postmaster children.
+ * necessity for manual cleanup of all postmaster children. Note
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
+ * if it is set, recheck with PostmasterIsAlive before believing it.
*/
- if (rc & WL_POSTMASTER_DEATH)
+ if ((rc & WL_POSTMASTER_DEATH) && !PostmasterIsAlive())
exit(1);
prev_hibernate = can_hibernate;
pg_time_t now;
int elapsed_secs;
int cur_timeout;
+ int rc;
/* Clear any already-pending wakeups */
ResetLatch(&MyProc->procLatch);
- /*
- * Emergency bailout if postmaster has died. This is to avoid the
- * necessity for manual cleanup of all postmaster children.
- */
- if (!PostmasterIsAlive())
- exit(1);
-
/*
* Process any requests or signals received recently.
*/
cur_timeout = Min(cur_timeout, XLogArchiveTimeout - elapsed_secs);
}
- (void) WaitLatch(&MyProc->procLatch,
- WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
- cur_timeout * 1000L /* convert to ms */);
+ rc = WaitLatch(&MyProc->procLatch,
+ WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
+ cur_timeout * 1000L /* convert to ms */);
+
+ /*
+ * Emergency bailout if postmaster has died. This is to avoid the
+ * necessity for manual cleanup of all postmaster children. Note
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
+ * if it is set, recheck with PostmasterIsAlive before believing it.
+ */
+ if ((rc & WL_POSTMASTER_DEATH) && !PostmasterIsAlive())
+ exit(1);
}
}
pgStatSock,
-1L);
- /* Check for postmaster death */
- if (wr & WL_POSTMASTER_DEATH)
+ /*
+ * Emergency bailout if postmaster has died. This is to avoid the
+ * necessity for manual cleanup of all postmaster children. Note
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
+ * if it is set, recheck with PostmasterIsAlive before believing it.
+ */
+ if ((wr & WL_POSTMASTER_DEATH) && !PostmasterIsAlive())
break;
} /* end of outer loop */
for (;;)
{
long cur_timeout;
+ int rc;
/*
* Advertise whether we might hibernate in this cycle. We do this
/* Clear any already-pending wakeups */
ResetLatch(&MyProc->procLatch);
- /*
- * Emergency bailout if postmaster has died. This is to avoid the
- * necessity for manual cleanup of all postmaster children.
- */
- if (!PostmasterIsAlive())
- exit(1);
-
/*
* Process any requests or signals received recently.
*/
else
cur_timeout = WalWriterDelay * HIBERNATE_FACTOR;
- (void) WaitLatch(&MyProc->procLatch,
- WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
- cur_timeout);
+ rc = WaitLatch(&MyProc->procLatch,
+ WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
+ cur_timeout);
+
+ /*
+ * Emergency bailout if postmaster has died. This is to avoid the
+ * necessity for manual cleanup of all postmaster children. Note
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
+ * if it is set, recheck with PostmasterIsAlive before believing it.
+ */
+ if ((rc & WL_POSTMASTER_DEATH) && !PostmasterIsAlive())
+ exit(1);
}
}