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
This commit is contained in:
Travis Cross 2014-02-11 05:33:25 +00:00
parent c52ac4817c
commit 3ae189ca3f
1 changed files with 5 additions and 1 deletions

View File

@ -196,7 +196,11 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted,
#if defined(SO_KEEPALIVE) #if defined(SO_KEEPALIVE)
setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val); setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val);
#endif #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 defined(TCP_KEEPIDLE)
if (val != 0 && val != UINT_MAX) if (val != 0 && val != UINT_MAX)
setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val); setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val);