From 90453ddf0640ebc54cf7d35c0f028553fc9f5703 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Wed, 15 Apr 2020 20:47:05 +0100 Subject: [PATCH] Fix compatibility with TCP_KEEPIDLE and Darwin Darwin uses for the same setting the TCP_KEEPALIVE option. Use TCP_KEEPALIVE instead of TCP_KEEPIDLE for Darwin. Signed-off-by: Frediano Ziglio --- server/net-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/net-utils.c b/server/net-utils.c index 78b94886..32ceb3b8 100644 --- a/server/net-utils.c +++ b/server/net-utils.c @@ -35,6 +35,10 @@ #include "net-utils.h" #include "sys-socket.h" +#if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) && defined(__APPLE__) +#define TCP_KEEPIDLE TCP_KEEPALIVE +#endif + /** * red_socket_set_keepalive: * @fd: a socket file descriptor @@ -57,7 +61,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout) return true; } -#ifdef HAVE_TCP_KEEPIDLE +#ifdef TCP_KEEPIDLE if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) { if (errno != ENOTSUP) { g_warning("setsockopt for keepalive timeout failed, %s", strerror(errno));