From 976060a8caae3ea92186e6acdf8bd7e52bbffae7 Mon Sep 17 00:00:00 2001 From: Matthew Nicholson Date: Thu, 5 May 2011 18:02:52 +0000 Subject: [PATCH] Set SO_KEEPALIVE on SIP TCP sockets so that they eventually go away when a peer abruptly disappears. This mostly occurs after a successful registration. (closes issue #17544) Reported by: marcelloceschia Patches: (modified) tcptls.patch uploaded by st (license 907) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317196 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index d5f982217e..37fc175b7a 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2524,6 +2524,12 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi } } + flags = 1; + if (setsockopt(tcptls_session->fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof(flags))) { + ast_log(LOG_ERROR, "error enabling TCP keep-alives on sip socket: %s\n", strerror(errno)); + goto cleanup; + } + me->threadid = pthread_self(); ast_debug(2, "Starting thread for %s server\n", tcptls_session->ssl ? "SSL" : "TCP"); -- 2.47.2