]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Make the keepalive stuff compile under FreeBSD
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Wed, 30 Nov 2022 16:53:38 +0000 (16:53 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Wed, 30 Nov 2022 16:53:38 +0000 (16:53 +0000)
rtsp.c

diff --git a/rtsp.c b/rtsp.c
index 7de596b685999d772dd296f6439974f89584d15f..c105ec0aff6951369acf3b6c54b0af6b8d1cb39c 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -5501,22 +5501,27 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) {
           // turn on keepalive stuff -- wait for keepidle + (keepcnt * keepinttvl time) seconds before giving up
           // an ETIMEOUT error is returned if the keepalive check fails
 
-          int flags = 35; // wait this many seconds before checking for a dropped client
-          if (setsockopt(conn->fd, SOL_TCP, TCP_KEEPIDLE, (void *)&flags, sizeof(flags))) {
+          int keepAliveIdleTime = 35; // wait this many seconds before checking for a dropped client
+          int keepAliveCount = 5; // check this many times
+          int keepAliveInterval = 5; // wait this many seconds between checks
+          
+#if defined COMPILE_FOR_BSD || defined COMPILE_FOR_OSX
+          #define SOL_OPTION IPPROTO_TCP
+#else
+          #define SOL_OPTION SOL_TCP
+#endif
+
+          if (setsockopt(conn->fd, SOL_OPTION, TCP_KEEPIDLE, (void *)&keepAliveIdleTime, sizeof(keepAliveIdleTime))) {
             debug(1,"can't set the keepidle wait time");
           }
 
-          flags = 5; // check this many times
-          if (setsockopt(conn->fd, SOL_TCP, TCP_KEEPCNT, (void *)&flags, sizeof(flags))) {
+          if (setsockopt(conn->fd, SOL_OPTION, TCP_KEEPCNT, (void *)&keepAliveCount, sizeof(keepAliveCount))) {
             debug(1,"can't set the keepidle missing count");
           }
-
-          flags = 5; // wait this many seconds between checks
-          if (setsockopt(conn->fd, SOL_TCP, TCP_KEEPINTVL, (void *)&flags, sizeof(flags))) {
+          if (setsockopt(conn->fd, SOL_OPTION  , TCP_KEEPINTVL, (void *)&keepAliveInterval, sizeof(keepAliveInterval))) {
             debug(1,"can't set the keepidle missing count interval");
-            exit(0);
           };
-
+       
           // initialise the connection info
           void *client_addr = NULL, *self_addr = NULL;
           conn->connection_ip_family = conn->local.SAFAMILY;