Module: kamailio
Branch: master
Commit: 45aa3fe81269abd3d9a644b4bd278afc194a3c53
URL:
https://github.com/kamailio/kamailio/commit/45aa3fe81269abd3d9a644b4bd278af…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-03-29T10:07:58+01:00
tcpops: set tcp keepalive values when available per option
- cover macos and *bsd for couple of options
---
Modified: src/modules/tcpops/tcpops.c
---
Diff:
https://github.com/kamailio/kamailio/commit/45aa3fe81269abd3d9a644b4bd278af…
Patch:
https://github.com/kamailio/kamailio/commit/45aa3fe81269abd3d9a644b4bd278af…
---
diff --git a/src/modules/tcpops/tcpops.c b/src/modules/tcpops/tcpops.c
index 9abf34af6e..3f66958b6c 100644
--- a/src/modules/tcpops/tcpops.c
+++ b/src/modules/tcpops/tcpops.c
@@ -130,8 +130,13 @@ int tcpops_acquire_fd_from_tcpmain(int conid, int *fd)
return 0;
}
-#if !defined(HAVE_SO_KEEPALIVE) || !defined(HAVE_TCP_KEEPIDLE) ||
!defined(HAVE_TCP_KEEPCNT) || !defined(HAVE_TCP_KEEPINTVL)
- #warning "TCP keepalive is not fully supported by your platform"
+#if !defined(HAVE_SO_KEEPALIVE) || !defined(HAVE_TCP_KEEPCNT) ||
!defined(HAVE_TCP_KEEPINTVL)
+ #define KSR_TCPOPS_NOKEEPALIVE
+#endif
+
+#ifdef KSR_TCPOPS_NOKEEPALIVE
+
+#warning "TCP keepalive options not supported by this platform"
int tcpops_keepalive_enable(int fd, int idle, int count, int interval, int closefd)
{
@@ -144,6 +149,7 @@ int tcpops_keepalive_disable(int fd, int closefd)
LM_ERR("tcp_keepalive_disable() failed: this module does not support your
platform\n");
return -1;
}
+
#else
int tcpops_keepalive_enable(int fd, int idle, int count, int interval, int closefd)
@@ -156,11 +162,15 @@ int tcpops_keepalive_enable(int fd, int idle, int count, int
interval, int close
LM_ERR("failed to enable SO_KEEPALIVE: %s\n", strerror(errno));
return -1;
} else {
-
+#ifdef HAVE_TCP_KEEPIDLE
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle,
sizeof(idle))<0){
LM_ERR("failed to set keepalive idle interval: %s\n", strerror(errno));
}
+#else
+ #warning "TCP_KEEPIDLE option not supported by this platform"
+ LM_DBG("TCP_KEEPIDLE option not available - ignoring\n");
+#endif
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count,
sizeof(count))<0){