diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-05 16:56:40 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-05 16:56:40 +0000 |
commit | 19e8dc973ba0b16d8c0b6efbe5da0ec516d74f7e (patch) | |
tree | c9043e8bd93e6a2a02aa9a04e2510a45f1772bc9 /channels | |
parent | 1290d19a8849791f9673e420888c1da4c51b1e73 (diff) |
ensure that threads which are supposed to be detached (because we aren't going to wait on them) are created properly
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@49635 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 14 | ||||
-rw-r--r-- | channels/chan_sip.c | 7 | ||||
-rw-r--r-- | channels/chan_skinny.c | 4 |
3 files changed, 20 insertions, 5 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 1adac13e2..2fa2cc2c5 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6210,13 +6210,18 @@ static void spawn_dp_lookup(int callno, char *context, char *callednum, char *ca 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 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2) } 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); } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 8dc37e504..f6627b990 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -10390,12 +10390,17 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct 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); } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 5f875104f..ca55bfcad 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -682,7 +682,6 @@ static int ourport; 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 @@ static void *accept_thread(void *ignore) 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 @@ static void *accept_thread(void *ignore) 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); } } |