]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4573 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 29 Aug 2012 16:46:36 +0000 (11:46 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 29 Aug 2012 16:46:36 +0000 (11:46 -0500)
src/include/private/switch_core_pvt.h
src/switch_core.c
src/switch_core_session.c

index 4483220ca3a697c4f6ba254ee9aee799f9fc61e8..56aaf48ff6ddab55417510b59a16833a8f4e86d2 100644 (file)
@@ -289,6 +289,7 @@ struct switch_session_manager {
        uint32_t session_limit;
        switch_size_t session_id;
        switch_queue_t *thread_queue;
+       switch_thread_t *manager_thread;
        switch_mutex_t *mutex;
        int ready;
        int running;
index 2102a70236624f16f090265eee6e4773d271e193..3f1a6d507522b1fc28b678c9b1487439ee4e71d6 100644 (file)
@@ -2461,7 +2461,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
                switch_nat_shutdown();
        }
        switch_xml_destroy();
-
+       switch_core_session_uninit();
        switch_console_shutdown();
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
index 1f499c14597a7586497344e66ce4557728765ba7..d017c767cfa4d5b06c8e5d548fa35db4b640d37e 100644 (file)
@@ -2230,15 +2230,13 @@ void switch_core_session_init(switch_memory_pool_t *pool)
        switch_core_hash_init(&session_manager.session_table, session_manager.memory_pool);
        
        if (switch_test_flag((&runtime), SCF_SESSION_THREAD_POOL)) {
-               switch_thread_t *thread;
                switch_threadattr_t *thd_attr;
 
                switch_mutex_init(&session_manager.mutex, SWITCH_MUTEX_NESTED, session_manager.memory_pool);
                switch_queue_create(&session_manager.thread_queue, 100000, session_manager.memory_pool);
                switch_threadattr_create(&thd_attr, session_manager.memory_pool);
-               switch_threadattr_detach_set(thd_attr, 1);
                switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-               switch_thread_create(&thread, thd_attr, switch_core_session_thread_pool_manager, NULL, session_manager.memory_pool);            
+               switch_thread_create(&session_manager.manager_thread, thd_attr, switch_core_session_thread_pool_manager, NULL, session_manager.memory_pool);            
                session_manager.ready = 1;
        }
 
@@ -2247,10 +2245,13 @@ void switch_core_session_init(switch_memory_pool_t *pool)
 void switch_core_session_uninit(void)
 {
        int sanity = 100;
+       switch_status_t st = SWITCH_STATUS_FALSE;
 
        switch_core_hash_destroy(&session_manager.session_table);
        session_manager.ready = 0;
 
+       switch_thread_join(&st, session_manager.manager_thread);
+
        while(session_manager.running && --sanity > 0) {
                switch_queue_interrupt_all(session_manager.thread_queue);
                switch_yield(100000);