From: Charles Davis Subject: [PATCH] ws2_32: Implement setting the keep-alive idle timeout and interval on Mac OS. Message-Id: <1438238316-38933-1-git-send-email-cdavis5x@gmail.com> Date: Thu, 30 Jul 2015 00:38:36 -0600 Mac OS has TCP_KEEPIDLE, but under the name TCP_KEEPALIVE. It's supported at least as far back as 10.6. TCP_KEEPINTVL was only added as of 10.9, so protect the code using it with an ifdef guard. --- dlls/ws2_32/socket.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index b06d7e7..81b7706 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -172,6 +172,11 @@ #define INADDR_NONE ~0UL #endif +#if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) +/* TCP_KEEPALIVE is the Mac OS name for TCP_KEEPIDLE */ +#define TCP_KEEPIDLE TCP_KEEPALIVE +#endif + WINE_DEFAULT_DEBUG_CHANNEL(winsock); WINE_DECLARE_DEBUG_CHANNEL(winediag); @@ -4459,14 +4464,20 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID fd = get_sock_fd(s, 0, NULL); if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(int)) == -1) status = WSAEINVAL; -#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) +#if defined(TCP_KEEPIDLE) /* these values need to be set only if SO_KEEPALIVE is enabled */ else if(keepalive) { if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&keepidle, sizeof(int)) == -1) status = WSAEINVAL; + /* TCP_KEEPINTVL was only introduced on Mac in 10.9 */ +#ifdef TCP_KEEPINTVL else if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepintvl, sizeof(int)) == -1) status = WSAEINVAL; +#else + else + FIXME("ignoring keepalive interval\n"); +#endif } #else else -- 2.4.5