[asterisk-commits] russell: branch 1.6.0 r163668 - in /branches/1.6.0: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 12 12:34:56 CST 2008


Author: russell
Date: Fri Dec 12 12:34:56 2008
New Revision: 163668

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

........
r163667 | russell | 2008-12-12 12:33:27 -0600 (Fri, 12 Dec 2008) | 5 lines

Fix a small race condition in sip_tcp_locate().

We must increase the reference count on the tcptls_session _before_ unlocking
the thread list.

........

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

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

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=163668&r1=163667&r2=163668
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Fri Dec 12 12:34:56 2008
@@ -18744,22 +18744,28 @@
 		return s.port == htons(STANDARD_SIP_PORT);
 }
 
-/*! \todo document this function. */
+/*! 
+ * \brief Find thread for TCP/TLS session (based on IP/Port 
+ *
+ * \note This function returns an astobj2 reference
+ */
 static struct ast_tcptls_session_instance *sip_tcp_locate(struct sockaddr_in *s)
 {
 	struct sip_threadinfo *th;
+	struct ast_tcptls_session_instance *tcptls_instance = NULL;
 
 	AST_LIST_LOCK(&threadl);
 	AST_LIST_TRAVERSE(&threadl, th, list) {
 		if ((s->sin_family == th->ser->requestor.sin_family) &&
 			(s->sin_addr.s_addr == th->ser->requestor.sin_addr.s_addr) &&
 			(s->sin_port == th->ser->requestor.sin_port))  {
-				AST_LIST_UNLOCK(&threadl);
-				return th->ser;
+				tcptls_instance = (ao2_ref(th->ser, +1), th->ser);
+				break;
 			}
 	}
 	AST_LIST_UNLOCK(&threadl);
-	return NULL;
+
+	return tcptls_instance;
 }
 
 /*! \todo document this function. */
@@ -18793,7 +18799,6 @@
 			ao2_ref(s->ser, -1);
 			s->ser = NULL;
 		}
-		ao2_ref(ser, +1);
 		s->ser = ser;
 		return s->fd;
 	}




More information about the asterisk-commits mailing list