From 51912c02157c6746b28aeddc3c19cde27e349fff Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 20 Jul 2020 09:17:55 -0400 Subject: [PATCH] roken: introduce rk_socket_set_keepalive Change-Id: I3086a10cd3d23bef00336f5db7db3a35ca02d568 --- lib/roken/roken-common.h | 4 ++++ lib/roken/socket.c | 10 ++++++++++ lib/roken/version-script.map | 1 + 3 files changed, 15 insertions(+) diff --git a/lib/roken/roken-common.h b/lib/roken/roken-common.h index 267643dc7..f2dc0ff4a 100644 --- a/lib/roken/roken-common.h +++ b/lib/roken/roken-common.h @@ -456,6 +456,10 @@ socket_set_reuseaddr (rk_socket_t, int); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_ipv6only (rk_socket_t, int); +#define socket_set_keepalive rk_socket_set_keepalive +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive (rk_socket_t, int); + #define socket_to_fd rk_socket_to_fd ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL socket_to_fd(rk_socket_t, int); diff --git a/lib/roken/socket.c b/lib/roken/socket.c index 0a8612557..9feb343f5 100644 --- a/lib/roken/socket.c +++ b/lib/roken/socket.c @@ -305,6 +305,16 @@ socket_set_ipv6only (rk_socket_t sock, int val) #endif } +/* + * Set the that the `sock' keepalive setting. + */ + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive(rk_socket_t sock, int val) +{ + setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof(val)); +} + /** * Create a file descriptor from a socket * diff --git a/lib/roken/version-script.map b/lib/roken/version-script.map index 1a996b102..5bef85e14 100644 --- a/lib/roken/version-script.map +++ b/lib/roken/version-script.map @@ -123,6 +123,7 @@ HEIMDAL_ROKEN_2.0 { rk_socket_set_any; rk_socket_set_debug; rk_socket_set_ipv6only; + rk_socket_set_keepalive; rk_socket_set_nonblocking; rk_socket_set_port; rk_socket_set_portrange;