Merged revisions 49636 via svnmerge from
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 5 Jan 2007 17:10:59 +0000 (17:10 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 5 Jan 2007 17:10:59 +0000 (17:10 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r49636 | kpfleming | 2007-01-05 11:09:00 -0600 (Fri, 05 Jan 2007) | 10 lines

Merged revisions 49635 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r49635 | kpfleming | 2007-01-05 10:56:40 -0600 (Fri, 05 Jan 2007) | 2 lines

ensure that threads which are supposed to be detached (because we aren't going to wait on them) are created properly

........

................

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49637 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/chan_sip.c
channels/chan_skinny.c

index d3b816b..46158be 100644 (file)
@@ -6134,16 +6134,20 @@ static void spawn_dp_lookup(int callno, const char *context, const char *calledn
 {
        pthread_t newthread;
        struct dpreq_data *dpr;
+       pthread_attr_t attr;
        
        if (!(dpr = ast_calloc(1, sizeof(*dpr))))
                return;
 
+       pthread_attr_init(&attr);
+       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);    
+
        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 = ast_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");
        }
 }
@@ -6213,9 +6217,14 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2)
                return -1;
        }
        if ((d = ast_calloc(1, sizeof(*d)))) {
+               pthread_attr_t attr;
+
+               pthread_attr_init(&attr);
+               pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
                d->chan1 = chan1m;
                d->chan2 = chan2m;
-               if (!ast_pthread_create_background(&th, NULL, iax_park_thread, d))
+               if (!ast_pthread_create_background(&th, &attr, iax_park_thread, d))
                        return 0;
                free(d);
        }
index 7159440..30a4bf7 100644 (file)
@@ -12751,12 +12751,17 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
                return -1;
        }
        if ((d = ast_calloc(1, sizeof(*d)))) {
+               pthread_attr_t attr;
+
+               pthread_attr_init(&attr);
+               pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);    
+
                /* Save original request for followup */
                copy_request(&d->req, req);
                d->chan1 = transferee;  /* Transferee */
                d->chan2 = transferer;  /* Transferer */
                d->seqno = seqno;
-               if (ast_pthread_create_background(&th, NULL, sip_park_thread, d) < 0) {
+               if (ast_pthread_create_background(&th, &attr, sip_park_thread, d) < 0) {
                        /* Could not start thread */
                        free(d);        /* We don't need it anymore. If thread is created, d will be free'd
                                           by sip_park_thread() */
index df0d1e4..927172e 100644 (file)
@@ -749,7 +749,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] = "";
@@ -4271,6 +4270,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);
@@ -4299,7 +4299,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);
                }
        }
@@ -4678,13 +4678,6 @@ static int unload_module(void)
        monitor_thread = AST_PTHREADT_STOP;
        ast_mutex_unlock(&monlock);
 
-       if (tcp_thread && (tcp_thread != AST_PTHREADT_STOP)) {
-               pthread_cancel(tcp_thread);
-               pthread_kill(tcp_thread, SIGURG);
-               pthread_join(tcp_thread, NULL);
-       }
-       tcp_thread = AST_PTHREADT_STOP;
-
        ast_mutex_lock(&netlock);
        if (accept_t && (accept_t != AST_PTHREADT_STOP)) {
                pthread_cancel(accept_t);