Skip to content

Commit 4c2b725

Browse files
Leonardo Alminanaedsiper
authored andcommitted
io: added tcp keepalive support
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent c32719c commit 4c2b725

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/flb_io.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ int flb_io_net_connect(struct flb_connection *connection,
156156
connection->upstream->tcp_port);
157157
}
158158

159+
/* set TCP keepalive and it's options */
160+
if (connection->net->tcp_keepalive) {
161+
ret = flb_net_socket_tcp_keepalive(connection->fd,
162+
connection->net);
163+
164+
if (ret == -1) {
165+
flb_socket_close(fd);
166+
167+
return -1;
168+
}
169+
}
170+
159171
#ifdef FLB_HAVE_TLS
160172
/* Check if TLS was enabled, if so perform the handshake */
161173
if (flb_stream_is_secure(connection->stream) &&

0 commit comments

Comments
 (0)