Skip to content

Commit 454aab4

Browse files
committed
postgres_fdw: Fix bug in connection status check.
The buildfarm member "hake" reported a failure in the regression test added by commit 857df3c, where postgres_fdw_get_connections(true) returned unexpected results. The function postgres_fdw_get_connections(true) checks if a connection is closed by using POLLRDHUP in the requested events and calling poll(). Previously, the function only considered POLLRDHUP or 0 as valid returned events. However, poll() can also return POLLHUP, POLLERR, and/or POLLNVAL. So if any of these events were returned, postgres_fdw_get_connections(true) would report incorrect results. postgres_fdw_get_connections(true) failed to account for these return events. This commit updates postgres_fdw_get_connections(true) to correctly report a closed connection when poll() returns not only POLLRDHUP but also POLLHUP, POLLERR, or POLLNVAL. Discussion: https://postgr.es/m/fd8f6186-9e1e-4b9a-92c5-e71e3697d381@oss.nttdata.com
1 parent 4b56bb4 commit 454aab4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/postgres_fdw/connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,8 @@ pgfdw_conn_check(PGconn *conn)
23092309
if (result < 0)
23102310
return -1;
23112311

2312-
return (input_fd.revents & POLLRDHUP) ? 1 : 0;
2312+
return (input_fd.revents &
2313+
(POLLRDHUP | POLLHUP | POLLERR | POLLNVAL)) ? 1 : 0;
23132314
}
23142315
#else
23152316
return 0;

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