Merged revisions 74045 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Mon, 9 Jul 2007 14:50:04 +0000 (14:50 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 9 Jul 2007 14:50:04 +0000 (14:50 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r74045 | file | 2007-07-09 11:49:05 -0300 (Mon, 09 Jul 2007) | 2 lines

Few minor thread synchronization tweaks. (issue #10124 reported by gzero)

........

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

channels/chan_skinny.c
pbx/pbx_dundi.c

index c7a718f..7022676 100644 (file)
@@ -5125,7 +5125,7 @@ static int unload_module(void)
        delete_devices();
 
        ast_mutex_lock(&monlock);
-       if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
+       if ((monitor_thread != AST_PTHREADT_NULL) && (monitor_thread != AST_PTHREADT_STOP)) {
                pthread_cancel(monitor_thread);
                pthread_kill(monitor_thread, SIGURG);
                pthread_join(monitor_thread, NULL);
index f420ffb..e63f903 100644 (file)
@@ -2123,6 +2123,9 @@ static void *network_thread(void *ignore)
                }
                check_password();
        }
+
+       netthreadid = AST_PTHREADT_NULL;
+       
        return NULL;
 }
 
@@ -2158,6 +2161,8 @@ static void *process_precache(void *ign)
                        sleep(1);
        }
 
+       precachethreadid = AST_PTHREADT_NULL;
+
        return NULL;
 }
 
@@ -4711,10 +4716,14 @@ static int unload_module(void)
 
        /* Stop all currently running threads */
        dundi_shutdown = 1;
-       pthread_kill(netthreadid, SIGURG);
-       pthread_join(netthreadid, NULL);
-       pthread_kill(precachethreadid, SIGURG);
-       pthread_join(precachethreadid, NULL);
+       if (netthreadid != AST_PTHREADT_NULL) {
+               pthread_kill(netthreadid, SIGURG);
+               pthread_join(netthreadid, NULL);
+       }
+       if (precachethreadid != AST_PTHREADT_NULL) {
+               pthread_kill(precachethreadid, SIGURG);
+               pthread_join(precachethreadid, NULL);
+       }
 
        ast_cli_unregister_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
        ast_unregister_switch(&dundi_switch);