diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-01-15 22:03:09 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-01-15 22:08:03 +0200 |
commit | b2b4af535eb733ba0c2ea6eeb2b14cac7f1ca4be (patch) | |
tree | 8bf07107a96fa487a013a1430c474f03b7cb5391 /src | |
parent | 0495aaad8b337642830a4d4e82f8b8c02b27b1be (diff) | |
download | postgresql-b2b4af535eb733ba0c2ea6eeb2b14cac7f1ca4be.tar.gz postgresql-b2b4af535eb733ba0c2ea6eeb2b14cac7f1ca4be.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/port/unix_latch.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/port/unix_latch.c b/src/backend/port/unix_latch.c index fc1a579ad2a..10bf2dbec7e 100644 --- a/src/backend/port/unix_latch.c +++ b/src/backend/port/unix_latch.c @@ -310,8 +310,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock, { 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) && - (pfds[nfds - 1].revents & POLLIN)) + (pfds[nfds - 1].revents & (POLLHUP | POLLIN | POLLERR | POLLNVAL))) { result |= WL_POSTMASTER_DEATH; } |