Rework handling of Linux TCP keepalives in Sofia
This separates out the Linux socket TCP keepalive timeout interval
from Sofia's internal mechanisms. Earlier we tied these together. In
retrospect this seems improper.
These two values can now be set separately.
You might, for example, want to keep the Sofia internal mechanism
disabled completely while enabling the platform-based mechanism if
your platform supports it.
We also here reform the default value of the socket TCP keepalive
parameter to 30 seconds.
This is what commit 1bf17857c9
should
have been.
FS-6104
This commit is contained in:
parent
f7c4dd79f5
commit
92e2caf86b
|
@ -142,6 +142,12 @@ TPORT_DLL extern tag_typedef_t tptag_timeout;
|
|||
TPORT_DLL extern tag_typedef_t tptag_timeout_ref;
|
||||
#define TPTAG_TIMEOUT_REF(x) tptag_timeout_ref, tag_uint_vr(&(x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_socket_keepalive;
|
||||
#define TPTAG_SOCKET_KEEPALIVE(x) tptag_socket_keepalive, tag_uint_v((x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_socket_keepalive_ref;
|
||||
#define TPTAG_SOCKET_KEEPALIVE_REF(x) tptag_socket_keepalive_ref, tag_uint_vr(&(x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_keepalive;
|
||||
#define TPTAG_KEEPALIVE(x) tptag_keepalive, tag_uint_v((x))
|
||||
|
||||
|
|
|
@ -520,6 +520,7 @@ tport_t *tport_tcreate(tp_stack_t *stack,
|
|||
tpp->tpp_idle = UINT_MAX;
|
||||
tpp->tpp_timeout = UINT_MAX;
|
||||
tpp->tpp_sigcomp_lifetime = UINT_MAX;
|
||||
tpp->tpp_socket_keepalive = 30;
|
||||
tpp->tpp_keepalive = 0;
|
||||
tpp->tpp_pingpong = 0;
|
||||
tpp->tpp_pong2ping = 0;
|
||||
|
@ -1215,6 +1216,7 @@ int tport_get_params(tport_t const *self,
|
|||
TPTAG_QUEUESIZE(tpp->tpp_qsize),
|
||||
TPTAG_IDLE(tpp->tpp_idle),
|
||||
TPTAG_TIMEOUT(tpp->tpp_timeout),
|
||||
TPTAG_SOCKET_KEEPALIVE(tpp->tpp_socket_keepalive),
|
||||
TPTAG_KEEPALIVE(tpp->tpp_keepalive),
|
||||
TPTAG_PINGPONG(tpp->tpp_pingpong),
|
||||
TPTAG_PONG2PING(tpp->tpp_pong2ping),
|
||||
|
@ -1280,6 +1282,7 @@ int tport_set_params(tport_t *self,
|
|||
TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)),
|
||||
TPTAG_IDLE_REF(tpp->tpp_idle),
|
||||
TPTAG_TIMEOUT_REF(tpp->tpp_timeout),
|
||||
TPTAG_SOCKET_KEEPALIVE_REF(tpp->tpp_socket_keepalive),
|
||||
TPTAG_KEEPALIVE_REF(tpp->tpp_keepalive),
|
||||
TPTAG_PINGPONG_REF(tpp->tpp_pingpong),
|
||||
TPTAG_PONG2PING_REF(pong2ping),
|
||||
|
|
|
@ -106,6 +106,7 @@ typedef struct {
|
|||
unsigned tpp_mtu; /**< Maximum packet size */
|
||||
unsigned tpp_idle; /**< Allowed connection idle time. */
|
||||
unsigned tpp_timeout; /**< Allowed idle time for message. */
|
||||
unsigned tpp_socket_keepalive;/**< Socket keepalive interval */
|
||||
unsigned tpp_keepalive; /**< Keepalive PING interval */
|
||||
unsigned tpp_pingpong; /**< PONG-to-PING interval */
|
||||
|
||||
|
|
|
@ -179,6 +179,14 @@ tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle);
|
|||
*/
|
||||
tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout);
|
||||
|
||||
/**@def TPTAG_SOCKET_KEEPALIVE(x)
|
||||
*
|
||||
* Keepalive interval set on socket (where supported) in seconds.
|
||||
*
|
||||
* If 0 or UINT_MAX, do not use keepalives. Default value is 30.
|
||||
*/
|
||||
tag_typedef_t tptag_socket_keepalive = UINTTAG_TYPEDEF(socket_keepalive);
|
||||
|
||||
/**@def TPTAG_KEEPALIVE(x)
|
||||
*
|
||||
* Keepalive interval in milliseconds.
|
||||
|
|
|
@ -196,11 +196,7 @@ 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 / 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));
|
||||
val = (int)(self->tp_params->tpp_socket_keepalive);
|
||||
#if defined(TCP_KEEPIDLE)
|
||||
if (val != 0 && val != UINT_MAX) {
|
||||
SU_DEBUG_3(("%s(%p): Setting TCP_KEEPIDLE to %d\n",
|
||||
|
|
Loading…
Reference in New Issue