Commit 31ad6553 authored by Tom Lane's avatar Tom Lane

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.
parent d36eaa21
...@@ -293,7 +293,7 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock, ...@@ -293,7 +293,7 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
result |= WL_TIMEOUT; result |= WL_TIMEOUT;
} }
if ((wakeEvents & WL_SOCKET_READABLE) && if ((wakeEvents & WL_SOCKET_READABLE) &&
(pfds[0].revents & POLLIN)) (pfds[0].revents & (POLLIN | POLLHUP | POLLERR | POLLNVAL)))
{ {
/* data available in socket */ /* data available in socket */
result |= WL_SOCKET_READABLE; result |= WL_SOCKET_READABLE;
......
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