Skip to content

Commit b2b4af5

Browse files
committed
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.
1 parent 0495aaa commit b2b4af5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/port/unix_latch.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,13 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
310310
{
311311
result |= WL_SOCKET_WRITEABLE;
312312
}
313+
/*
314+
* We expect a POLLHUP when the remote end is closed, but because we
315+
* don't expect the pipe to become readable or to have any errors
316+
* either, treat those as postmaster death, too.
317+
*/
313318
if ((wakeEvents & WL_POSTMASTER_DEATH) &&
314-
(pfds[nfds - 1].revents & POLLIN))
319+
(pfds[nfds - 1].revents & (POLLHUP | POLLIN | POLLERR | POLLNVAL)))
315320
{
316321
result |= WL_POSTMASTER_DEATH;
317322
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy