Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a07363c

Browse files
knizhnikkelvich
authored andcommitted
Set SO_KEEPALIVE
1 parent dc4fb75 commit a07363c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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)