[asterisk-commits] dvossel: branch dvossel/sip_nonblocking_tcp_client r220546 - in /team/dvossel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 25 15:08:46 CDT 2009


Author: dvossel
Date: Fri Sep 25 15:08:42 2009
New Revision: 220546

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=220546
Log:
This makes sure the correct transport type is set for the threadinfo object


Modified:
    team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c
    team/dvossel/sip_nonblocking_tcp_client/main/tcptls.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=220546&r1=220545&r2=220546
==============================================================================
--- team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c (original)
+++ team/dvossel/sip_nonblocking_tcp_client/channels/chan_sip.c Fri Sep 25 15:08:42 2009
@@ -2943,7 +2943,7 @@
 	}
 }
 
-static struct sip_threadinfo *sip_threadinfo_create(struct ast_tcptls_session_instance *tcptls_session)
+static struct sip_threadinfo *sip_threadinfo_create(struct ast_tcptls_session_instance *tcptls_session, int transport)
 {
 	struct sip_threadinfo *th;
 
@@ -2959,7 +2959,7 @@
 	}
 	ao2_t_ref(tcptls_session, +1, "tcptls_session ref for sip_threadinfo object");
 	th->tcptls_session = tcptls_session;
-	th->type = tcptls_session->ssl ? SIP_TRANSPORT_TLS: SIP_TRANSPORT_TCP;
+	th->type = transport ? transport : (tcptls_session->ssl ? SIP_TRANSPORT_TLS: SIP_TRANSPORT_TCP);
 	ao2_t_link(threadl, th, "Adding new tcptls helper thread");
 	ao2_t_ref(th, -1, "Decrementing threadinfo ref from alloc, only table ref remains");
 	return th;
@@ -3056,7 +3056,7 @@
 	 * A threadinfo object has 2 references once it is created, one for the table, and one for this thread.
 	 */
 	if (!tcptls_session->client) {
-		if (!(me = sip_threadinfo_create(tcptls_session))) {
+		if (!(me = sip_threadinfo_create(tcptls_session, tcptls_session->ssl ? SIP_TRANSPORT_TLS : SIP_TRANSPORT_TCP))) {
 			goto cleanup2;
 		}
 		ao2_t_ref(me, +1, "Adding threadinfo ref for tcp_helper_thread");
@@ -3064,12 +3064,10 @@
 		struct sip_threadinfo tmp = {
 			.tcptls_session = tcptls_session,
 		};
-		ca = tcptls_session->parent;
 		if (!(me = ao2_t_find(threadl, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread"))) {
 			goto cleanup2;
 		}
-
-		if (!(tcptls_session = ast_tcptls_client_start(tcptls_session))) {
+		if (!(ca = tcptls_session->parent) || !(tcptls_session = ast_tcptls_client_start(tcptls_session))) {
 			goto cleanup;
 		}
 	}
@@ -22931,7 +22929,7 @@
 	 * the thread is detached.  This ensures the alert_pipe is up before it will
 	 * be used.  Note that this function links the new threadinfo object into the
 	 * threadl container. */
-	if (!(th = sip_threadinfo_create(s->tcptls_session))) {
+	if (!(th = sip_threadinfo_create(s->tcptls_session, s->type))) {
 		goto create_tcptls_session_fail;
 	}
 

Modified: team/dvossel/sip_nonblocking_tcp_client/main/tcptls.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_nonblocking_tcp_client/main/tcptls.c?view=diff&rev=220546&r1=220545&r2=220546
==============================================================================
--- team/dvossel/sip_nonblocking_tcp_client/main/tcptls.c (original)
+++ team/dvossel/sip_nonblocking_tcp_client/main/tcptls.c Fri Sep 25 15:08:42 2009
@@ -125,7 +125,7 @@
 *
 * \note must decrement ref count before returning NULL on error
 */
-static void *handle_tls_connection(void *data)
+static void *handle_tcptls_connection(void *data)
 {
 	struct ast_tcptls_session_instance *tcptls_session = data;
 #ifdef DO_SSL
@@ -267,7 +267,7 @@
 		tcptls_session->client = 0;
 
 		/* This thread is now the only place that controls the single ref to tcptls_session */
-		if (ast_pthread_create_detached_background(&launched, NULL, handle_tls_connection, tcptls_session)) {
+		if (ast_pthread_create_detached_background(&launched, NULL, handle_tcptls_connection, tcptls_session)) {
 			ast_log(LOG_WARNING, "Unable to launch helper thread: %s\n", strerror(errno));
 			close(tcptls_session->fd);
 			ao2_ref(tcptls_session, -1);
@@ -363,7 +363,7 @@
  */
 struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session)
 {
-	return handle_tls_connection(tcptls_session);
+	return handle_tcptls_connection(tcptls_session);
 }
 
 struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_session_args *desc)




More information about the asterisk-commits mailing list