[asterisk-commits] kpfleming: branch 1.2 r49635 - /branches/1.2/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 5 09:56:41 MST 2007


Author: kpfleming
Date: Fri Jan  5 10:56:40 2007
New Revision: 49635

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49635
Log:
ensure that threads which are supposed to be detached (because we aren't going to wait on them) are created properly

Modified:
    branches/1.2/channels/chan_iax2.c
    branches/1.2/channels/chan_sip.c
    branches/1.2/channels/chan_skinny.c

Modified: branches/1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_iax2.c?view=diff&rev=49635&r1=49634&r2=49635
==============================================================================
--- branches/1.2/channels/chan_iax2.c (original)
+++ branches/1.2/channels/chan_iax2.c Fri Jan  5 10:56:40 2007
@@ -6210,13 +6210,18 @@
 	struct dpreq_data *dpr;
 	dpr = malloc(sizeof(struct dpreq_data));
 	if (dpr) {
+		pthread_attr_t attr;
+
+		pthread_attr_init(&attr);
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);	
+
 		memset(dpr, 0, sizeof(struct dpreq_data));
 		dpr->callno = callno;
 		ast_copy_string(dpr->context, context, sizeof(dpr->context));
 		ast_copy_string(dpr->callednum, callednum, sizeof(dpr->callednum));
 		if (callerid)
 			dpr->callerid = strdup(callerid);
-		if (ast_pthread_create(&newthread, NULL, dp_lookup_thread, dpr)) {
+		if (ast_pthread_create(&newthread, &attr, dp_lookup_thread, dpr)) {
 			ast_log(LOG_WARNING, "Unable to start lookup thread!\n");
 		}
 	} else
@@ -6291,10 +6296,15 @@
 	}
 	d = malloc(sizeof(struct iax_dual));
 	if (d) {
+		pthread_attr_t attr;
+
+		pthread_attr_init(&attr);
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
 		memset(d, 0, sizeof(*d));
 		d->chan1 = chan1m;
 		d->chan2 = chan2m;
-		if (!ast_pthread_create(&th, NULL, iax_park_thread, d))
+		if (!ast_pthread_create(&th, &attr, iax_park_thread, d))
 			return 0;
 		free(d);
 	}

Modified: branches/1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_sip.c?view=diff&rev=49635&r1=49634&r2=49635
==============================================================================
--- branches/1.2/channels/chan_sip.c (original)
+++ branches/1.2/channels/chan_sip.c Fri Jan  5 10:56:40 2007
@@ -10390,12 +10390,17 @@
 	ast_mutex_unlock(&chan2m->lock);
 	d = malloc(sizeof(struct sip_dual));
 	if (d) {
+		pthread_attr_t attr;
+
+		pthread_attr_init(&attr);
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);	
+
 		memset(d, 0, sizeof(*d));
 		/* Save original request for followup */
 		copy_request(&d->req, req);
 		d->chan1 = chan1m;
 		d->chan2 = chan2m;
-		if (!ast_pthread_create(&th, NULL, sip_park_thread, d))
+		if (!ast_pthread_create(&th, &attr, sip_park_thread, d))
 			return 0;
 		free(d);
 	}

Modified: branches/1.2/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_skinny.c?view=diff&rev=49635&r1=49634&r2=49635
==============================================================================
--- branches/1.2/channels/chan_skinny.c (original)
+++ branches/1.2/channels/chan_skinny.c Fri Jan  5 10:56:40 2007
@@ -682,7 +682,6 @@
 static struct in_addr __ourip;
 struct ast_hostent ahp; struct hostent *hp;
 static int skinnysock  = -1;
-static pthread_t tcp_thread;
 static pthread_t accept_t;
 static char context[AST_MAX_CONTEXT] = "default";
 static char language[MAX_LANGUAGE] = "";
@@ -2938,6 +2937,7 @@
 	struct protoent *p;
 	int arg = 1;
 	pthread_attr_t attr;
+	pthread_t tcp_thread;
 
 	pthread_attr_init(&attr);
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -2969,7 +2969,7 @@
 		sessions = s;
 		ast_mutex_unlock(&sessionlock);
 		
-		if (ast_pthread_create(&tcp_thread, NULL, skinny_session, s)) {
+		if (ast_pthread_create(&tcp_thread, &attr, skinny_session, s)) {
 			destroy_session(s);
 		}
 	}



More information about the asterisk-commits mailing list