Skip to content

Commit f17549f

Browse files
committed
Fix logic of platform-depended sockoptions
1 parent af41cb5 commit f17549f

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ setKeepalivesIdle(PGconn *conn)
14451445
idle = 0;
14461446

14471447
#ifdef PG_TCP_KEEPALIVE_IDLE
1448-
if (pg_setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPIDLE,
1448+
if (pg_setsockopt(conn->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
14491449
(char *) &idle, sizeof(idle), conn->isRsocket) < 0)
14501450
{
14511451
char sebuf[256];
@@ -1456,20 +1456,6 @@ setKeepalivesIdle(PGconn *conn)
14561456
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
14571457
return 0;
14581458
}
1459-
#else
1460-
#ifdef TCP_KEEPALIVE
1461-
/* Darwin uses TCP_KEEPALIVE rather than TCP_KEEPIDLE */
1462-
if (pg_setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPALIVE,
1463-
(char *) &idle, sizeof(idle), conn->isRsocket) < 0)
1464-
{
1465-
char sebuf[256];
1466-
1467-
appendPQExpBuffer(&conn->errorMessage,
1468-
libpq_gettext("setsockopt(TCP_KEEPALIVE) failed: %s\n"),
1469-
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
1470-
return 0;
1471-
}
1472-
#endif
14731459
#endif
14741460

14751461
return 1;

0 commit comments

Comments
 (0)