8000 Set SO_KEEPALIVE · postgrespro/postgres_cluster@1a8c8c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a8c8c5

Browse files
committed
Set SO_KEEPALIVE
1 parent 4696afa commit 1a8c8c5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

contrib/mmts/arbiter.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,15 @@ static int MtmReadSocket(int sd, void* buf, int buf_size)
239239
static void MtmSetSocketOptions(int sd)
240240
{
241241
#ifdef TCP_NODELAY
242-
int optval = 1;
243-
if (setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char const*)&optval, sizeof(optval)) < 0) {
242+
int on = 1;
243+
if (setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char const*)&on, sizeof(on)) < 0) {
244244
elog(WARNING, "Failed to set TCP_NODELAY: %m");
245245
}
246246
#endif
247+
if (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (char const*)&on, sizeof(on)) < 0) {
248+
elog(WARNING, "Failed to set SO_KEEPALIVE: %m");
249+
}
250+
247251
if (tcp_keepalives_idle) {
248252
#ifdef TCP_KEEPIDLE
249253
if (setsockopt(sd, IPPROTO_TCP, TCP_KEEPIDLE,

0 commit comments

Comments
 (0)
0