Commit b2b4af53 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix poll() implementation of WaitLatchOrSocket to notice postmaster death.

When the remote end of the pipe is closed, select() reports the fd as
readable, but poll() has a separate POLLHUP return code for that.

Spotted by Peter Geoghegan.
parent 0495aaad
...@@ -310,8 +310,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock, ...@@ -310,8 +310,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
{ {
result |= WL_SOCKET_WRITEABLE; result |= WL_SOCKET_WRITEABLE;
} }
/*
* We expect a POLLHUP when the remote end is closed, but because we
* don't expect the pipe to become readable or to have any errors
* either, treat those as postmaster death, too.
*/
if ((wakeEvents & WL_POSTMASTER_DEATH) && if ((wakeEvents & WL_POSTMASTER_DEATH) &&
(pfds[nfds - 1].revents & POLLIN)) (pfds[nfds - 1].revents & (POLLHUP | POLLIN | POLLERR | POLLNVAL)))
{ {
result |= WL_POSTMASTER_DEATH; result |= WL_POSTMASTER_DEATH;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment