Skip to content

Commit 7e32d6f

Browse files
committed
Fix logic of platform-depended sockoptions
1 parent 203bcae commit 7e32d6f

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,23 +1731,13 @@ pq_getkeepalivesidle(Port *port)
17311731
#ifndef WIN32
17321732
ACCEPT_TYPE_ARG3 size = sizeof(port->default_keepalives_idle);
17331733

1734-
#ifdef TCP_KEEPIDLE
1735-
if (pg_getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPIDLE,
1736-
(char *) &port->default_keepalives_idle,
1737-
&size, port->isRsocket) < 0)
1738-
{
1739-
elog(LOG, "getsockopt(TCP_KEEPIDLE) failed: %m");
1740-
port->default_keepalives_idle = -1; /* don't know */
1741-
}
1742-
#else
1743-
if (pg_getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPALIVE,
1734+
if (pg_getsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
17441735
(char *) &port->default_keepalives_idle,
17451736
&size, port->isRsocket) < 0)
17461737
{
17471738
elog(LOG, "getsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
17481739
port->default_keepalives_idle = -1; /* don't know */
17491740
}
1750-
#endif
17511741
#else /* WIN32 */
17521742
/* We can't get the defaults on Windows, so return "don't know" */
17531743
port->default_keepalives_idle = -1;
@@ -1786,21 +1776,12 @@ pq_setkeepalivesidle(int idle, Port *port)
17861776
if (idle == 0)
17871777
idle = port->default_keepalives_idle;
17881778

1789-
#ifdef TCP_KEEPIDLE
1790-
if (pg_setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPIDLE,
1779+
if (pg_setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
17911780
(char *) &idle, sizeof(idle), port->isRsocket) < 0)
17921781
{
17931782
elog(LOG, "setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
17941783
return STATUS_ERROR;
17951784
}
1796-
#else
1797-
if (pg_setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPALIVE,
1798-
(char *) &idle, sizeof(idle), port->isRsocket) < 0)
1799-
{
1800-
elog(LOG, "setsockopt(TCP_KEEPALIVE) failed: %m");
1801-
return STATUS_ERROR;
1802-
}
1803-
#endif
18041785

18051786
port->keepalives_idle = idle;
18061787
#else /* WIN32 */

0 commit comments

Comments
 (0)