Merge "pbx_dundi.c: Handle thread shutdown better."
authorGeorge Joseph <gjoseph@digium.com>
Tue, 21 Aug 2018 12:26:01 +0000 (07:26 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Tue, 21 Aug 2018 12:26:01 +0000 (07:26 -0500)
1  2 
pbx/pbx_dundi.c

diff --cc pbx/pbx_dundi.c
@@@ -4996,19 -4961,25 +4990,22 @@@ static int unload_module(void
  
        /* Stop all currently running threads */
        dundi_shutdown = 1;
-       if (previous_netthreadid != AST_PTHREADT_NULL) {
-               pthread_kill(previous_netthreadid, SIGURG);
-               pthread_join(previous_netthreadid, NULL);
-       }
-       if (previous_precachethreadid != AST_PTHREADT_NULL) {
-               pthread_kill(previous_precachethreadid, SIGURG);
-               pthread_join(previous_precachethreadid, NULL);
-       }
-       if (previous_clearcachethreadid != AST_PTHREADT_NULL) {
-               pthread_cancel(previous_clearcachethreadid);
-               pthread_join(previous_clearcachethreadid, NULL);
+       if (netthreadid != AST_PTHREADT_NULL) {
+               pthread_kill(netthreadid, SIGURG);
+               pthread_join(netthreadid, NULL);
+               netthreadid = AST_PTHREADT_NULL;
+       }
+       if (precachethreadid != AST_PTHREADT_NULL) {
+               pthread_kill(precachethreadid, SIGURG);
+               pthread_join(precachethreadid, NULL);
+               precachethreadid = AST_PTHREADT_NULL;
+       }
+       if (clearcachethreadid != AST_PTHREADT_NULL) {
+               pthread_cancel(clearcachethreadid);
+               pthread_join(clearcachethreadid, NULL);
+               clearcachethreadid = AST_PTHREADT_NULL;
        }
  
 -      close(netsocket);
 -      io_context_destroy(io);
 -
        mark_mappings();
        prune_mappings();
        mark_peers();