]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix shutdown race
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Feb 2008 20:26:06 +0000 (20:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 15 Feb 2008 20:26:06 +0000 (20:26 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@395 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/zap_analog.c
libs/openzap/src/zap_io.c

index b4c108746261d74827f783ea0fdc97fc8cfebbab..ef9d696dc5d8ff8ab131f04671eb4df79d849b6f 100644 (file)
@@ -218,7 +218,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
        
        assert(interval != 0);
 
-       while (zap_test_flag(zchan, ZAP_CHANNEL_INTHREAD)) {
+       while (zap_running() && zap_test_flag(zchan, ZAP_CHANNEL_INTHREAD)) {
                zap_wait_flag_t flags = ZAP_READ;
                zap_size_t dlen = 0;
                
index 2987164c69263b287e1c8a7a7141276e8b3d2a56..05a26beda2ab9a7e111f0ece68fad200e7ab2da8 100644 (file)
@@ -233,6 +233,11 @@ static zap_status_t zap_channel_destroy(zap_channel_t *zchan)
 
        if (zap_test_flag(zchan, ZAP_CHANNEL_CONFIGURED)) {
 
+               while (zap_test_flag(zchan, ZAP_CHANNEL_INTHREAD)) {
+                       zap_log(ZAP_LOG_INFO, "Waiting for thread to exit on channel %u:%u\n", zchan->span_id, zchan->chan_id);
+                       zap_sleep(500);
+               }
+
                zap_buffer_destroy(&zchan->digit_buffer);
                zap_buffer_destroy(&zchan->dtmf_buffer);
                zap_buffer_destroy(&zchan->fsk_buffer);
@@ -1993,9 +1998,9 @@ zap_status_t zap_global_destroy(void)
 {
        unsigned int i,j;
        time_end();
-       
+
+       globals.running = 0;    
        zap_span_close_all();
-       globals.running = 0;
        zap_sleep(1000);
 
        for(i = 1; i <= globals.span_index; i++) {