[asterisk-commits] dvossel: branch dvossel/sip_nonblocking_tcp_client r220671 - /team/dvossel/si...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 28 10:22:23 CDT 2009


Author: dvossel
Date: Mon Sep 28 10:22:18 2009
New Revision: 220671

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=220671
Log:
Cleaned up some comments


Modified:
    team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c

Modified: team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c?view=diff&rev=220671&r1=220670&r2=220671
==============================================================================
--- team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c (original)
+++ team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c Mon Sep 28 10:22:18 2009
@@ -3047,31 +3047,34 @@
 {
 	int res, cl;
 	struct sip_request req = { 0, } , reqcpy = { 0, };
-	struct sip_threadinfo *me;
+	struct sip_threadinfo *me = NULL;
 	char buf[1024] = "";
 	struct pollfd fds[2] = { { 0 }, { 0 }, };
 	struct ast_tcptls_session_args *ca = NULL;
 
-	/* If this is a server connection, create a new thread info object.
+	/* If this is a server session, then the connection has already been setup,
+	 * simply create the threadinfo object so we can access this thread for writing.
 	 * 
-	 * else if this is a client connection, we have already created a thread info
-	 * object and linked it to the threadl container, find it.
-	 *
-	 * A threadinfo object has 2 references once it is created, one for the table, and one for this thread.
+	 * if this is a client connection more work must be done.
+	 * 1. We own the parent session args for a client connection.  This pointer needs
+	 *    to be held on to so we can decrement it's ref count on thread destruction.
+	 * 2. The threadinfo object was created before this thread was launched, however
+	 *    it must be found within the threadl table.
+	 * 3. Last, the tcptls_session must be started.
 	 */
 	if (!tcptls_session->client) {
 		if (!(me = sip_threadinfo_create(tcptls_session, tcptls_session->ssl ? SIP_TRANSPORT_TLS : SIP_TRANSPORT_TCP))) {
-			goto cleanup2;
+			goto cleanup;
 		}
 		ao2_t_ref(me, +1, "Adding threadinfo ref for tcp_helper_thread");
 	} else {
 		struct sip_threadinfo tmp = {
 			.tcptls_session = tcptls_session,
 		};
-		if (!(me = ao2_t_find(threadl, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread"))) {
-			goto cleanup2;
-		}
-		if (!(ca = tcptls_session->parent) || !(tcptls_session = ast_tcptls_client_start(tcptls_session))) {
+
+		if ((!(ca = tcptls_session->parent)) ||
+			(!(me = ao2_t_find(threadl, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread"))) ||
+			(!(tcptls_session = ast_tcptls_client_start(tcptls_session)))) {
 			goto cleanup;
 		}
 	}
@@ -3216,9 +3219,10 @@
 	}
 
 cleanup:
-	ao2_t_unlink(threadl, me, "Removing tcptls helper thread, thread is closing");
-	ao2_t_ref(me, -1, "Removing tcp_helper_threads threadinfo ref");
-cleanup2:
+	if (me) {
+		ao2_t_unlink(threadl, me, "Removing tcptls helper thread, thread is closing");
+		ao2_t_ref(me, -1, "Removing tcp_helper_threads threadinfo ref");
+	}
 	if (reqcpy.data) {
 		ast_free(reqcpy.data);
 	}
@@ -22853,7 +22857,8 @@
 	/* check to see if a socket is already active */
 	if ((s->fd != -1) && (s->type == SIP_TRANSPORT_UDP)) {
 		return s->fd;
-	} else if ((s->type & (SIP_TRANSPORT_TCP | SIP_TRANSPORT_TLS)) &&
+	}
+	if ((s->type & (SIP_TRANSPORT_TCP | SIP_TRANSPORT_TLS)) &&
 			(s->tcptls_session) &&
 			(s->tcptls_session->fd != -1)) {
 		return s->tcptls_session->fd;
@@ -22900,7 +22905,6 @@
 	if (!(ca = ao2_alloc(sizeof(*ca), sip_tcptls_client_args_destructor))) {
 		goto create_tcptls_session_fail;
 	}
-
 	ca->name = ast_strdup(name);
 	ca->accept_fd = -1;
 	ca->remote_address = *(sip_real_dst(p));




More information about the asterisk-commits mailing list