From 3ae189ca3f81ab2548c136bea322405517635588 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 11 Feb 2014 05:33:25 +0000 Subject: [PATCH] Synchronize Sofia and Linux TCP keepalive timeout units Sofia keeps the TCP keepalive timeout in milliseconds, but Linux expects the value in seconds. Before this change, it's unlikely the TCP_KEEPIDLE and TCP_KEEPINTVL calls were having much effect as we would have been passing them a huge value. FS-6104 --- libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c index 70cf64385b..14601f49ff 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_tcp.c @@ -196,7 +196,11 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted, #if defined(SO_KEEPALIVE) setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val); #endif - val = (int)(self->tp_params->tpp_keepalive); + val = (int)(self->tp_params->tpp_keepalive / 1000); + if (!val && (self->tp_params->tpp_keepalive > 0)) + SU_DEBUG_1(("%s(%p): Ignoring TCP keepalive value %u (<1000)\n", + __func__, (void *)self, + self->tp_params->tpp_keepalive)); #if defined(TCP_KEEPIDLE) if (val != 0 && val != UINT_MAX) setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val);