Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 31ad655

Browse files
committed
Fix WaitLatchOrSocket to handle EOF on socket correctly.
When using poll(), EOF on a socket is reported with the POLLHUP not POLLIN flag (at least on Linux). WaitLatchOrSocket failed to check this bit, causing it to go into a busy-wait loop if EOF occurs. We earlier fixed the same mistake in the test for the state of the postmaster_alive socket, but missed it for the caller-supplied socket. Fortunately, this error is new in 9.2, since 9.1 only had a select() based code path not a poll() based one.
1 parent d36eaa2 commit 31ad655

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/port/unix_latch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
293293
result |= WL_TIMEOUT;
294294
}
295295
if ((wakeEvents & WL_SOCKET_READABLE) &&
296-
(pfds[0].revents & POLLIN))
296+
(pfds[0].revents & (POLLIN | POLLHUP | POLLERR | POLLNVAL)))
297297
{
298298
/* data available in socket */
299299
result |= WL_SOCKET_READABLE;

0 commit comments

Comments
 (0)