From: Matthew Nicholson Date: Thu, 5 May 2011 17:59:13 +0000 (+0000) Subject: Set SO_KEEPALIVE on SIP TCP sockets so that they eventually go away when a peer X-Git-Tag: 1.6.2.19-rc1~3^2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9bf3d604ea2e4e559388343ca9682b4432efe7f;p=thirdparty%2Fasterisk.git 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.6.2@317195 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ce8637d8c1..4dfa20c51d 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3002,6 +3002,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");