[svn-commits] dvossel: branch 1.6.1 r189774 - in /branches/1.6.1: ./ channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Apr 21 15:42:59 CDT 2009


Author: dvossel
Date: Tue Apr 21 15:42:55 2009
New Revision: 189774

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=189774
Log:
Merged revisions 189771 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r189771 | dvossel | 2009-04-21 15:28:37 -0500 (Tue, 21 Apr 2009) | 11 lines
  
  Fixes segfault when switching UDP to TCP in sip.conf after reload.
  
  If transport in sip.conf is switched from UDP to TCP, Asterisk segfaults right after issuing a sip reload.  The problem is the socket type is changed to TCP but the fd may still be present for UDP.  Later, when the TCP session should be created or set using an existing one, it isn't because the old file descriptor is still present.  Now every time transport is changed during a sip.conf reload, the file descriptor is set to -1, signifying it must be created or found.
  
  (closes issue #14727)
  Reported by: pj
  Tested by: dvossel
  
  Review: http://reviewboard.digium.com/r/229/
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/channels/chan_sip.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.1/channels/chan_sip.c?view=diff&rev=189774&r1=189773&r2=189774
==============================================================================
--- branches/1.6.1/channels/chan_sip.c (original)
+++ branches/1.6.1/channels/chan_sip.c Tue Apr 21 15:42:55 2009
@@ -2875,14 +2875,18 @@
 	if (p->socket.tcptls_session)
 		ast_mutex_lock(&p->socket.tcptls_session->lock);
 
-	if (p->socket.type & SIP_TRANSPORT_UDP) 
+	if (p->socket.type & SIP_TRANSPORT_UDP) {
 		res = sendto(p->socket.fd, data->str, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
-	else {
-		if (p->socket.tcptls_session->f) 
+	} else if (p->socket.tcptls_session) {
+		if (p->socket.tcptls_session->f) {
 			res = ast_tcptls_server_write(p->socket.tcptls_session, data->str, len);
-		else
+		} else {
 			ast_debug(2, "No p->socket.tcptls_session->f len=%d\n", len);
-	} 
+		}
+	} else {
+		ast_debug(2, "Socket type is TCP but no tcptls_session is present to write to\n");
+		return XMIT_ERROR;
+	}
 
 	if (p->socket.tcptls_session)
 		ast_mutex_unlock(&p->socket.tcptls_session->lock);
@@ -21654,8 +21658,10 @@
 				else
 					ast_log(LOG_NOTICE, "'%s' is not a valid transport type. if no other is specified, udp will be used.\n", trans);
 
-				if (!peer->socket.type) /*!< The first transport listed should be used for outgoing */
+				if (!peer->socket.type) { /*!< The first transport listed should be used for outgoing */
 					peer->socket.type = peer->transports;
+					peer->socket.fd = -1;
+				}
 			}
 		} else if (realtime && !strcasecmp(v->name, "regseconds")) {
 			ast_get_time_t(v->value, &regseconds, 0, NULL);




More information about the svn-commits mailing list