[Spice-devel] [spice-server v4 6/6] build-sys: Add configure check for TCP_KEEPIDLE

Christophe Fergeau cfergeau at redhat.com
Fri Mar 31 09:21:36 UTC 2017


This is only available in newer FreeBSD releases (9.1 and later), and
will cause build errors or older versions

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=99213

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
---
 configure.ac       | 5 +++++
 server/net-utils.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index c2a6c2d..66b9a17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,11 @@ AC_C_BIGENDIAN
 PKG_PROG_PKG_CONFIG
 
 AC_CHECK_HEADERS([sys/time.h execinfo.h linux/sockios.h])
+AC_CHECK_DECL([TCP_KEEPIDLE], [have_tcp_keepidle="yes"],,
+              [#include <netinet/tcp.h>])
+AS_IF([test "x$have_tcp_keepidle" = "xyes"],
+      [AC_DEFINE([HAVE_TCP_KEEPIDLE],1,[Define to 1 if <netinet/tcp.h> has a TCP_KEEPIDLE definition])],
+)
 AC_FUNC_ALLOCA
 
 SPICE_LT_VERSION=m4_format("%d:%d:%d", SPICE_CURRENT, SPICE_REVISION, SPICE_AGE)
diff --git a/server/net-utils.c b/server/net-utils.c
index 209c298..06fb8b1 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -53,12 +53,14 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
         return true;
     }
 
+#ifdef HAVE_TCP_KEEPIDLE
     if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
         if (errno != ENOTSUP) {
             spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
             return false;
         }
     }
+#endif
 
     return true;
 }
-- 
2.9.3



More information about the Spice-devel mailing list