提交 0562e38a authored 作者: Anthony Minessale's avatar Anthony Minessale

add proper shutdown to mod_conference

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2302 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 5782555e
...@@ -53,6 +53,8 @@ static struct { ...@@ -53,6 +53,8 @@ static struct {
switch_mutex_t *id_mutex; switch_mutex_t *id_mutex;
switch_mutex_t *hash_mutex; switch_mutex_t *hash_mutex;
uint32_t id_pool; uint32_t id_pool;
int32_t running;
uint32_t threads;
} globals; } globals;
struct conference_member; struct conference_member;
...@@ -451,7 +453,9 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v ...@@ -451,7 +453,9 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
return NULL; return NULL;
} }
while(!switch_test_flag(conference, CFLAG_DESTRUCT)) { globals.threads++;
while(globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
uint8_t file_frame[CONF_BUFFER_SIZE] = {0}; uint8_t file_frame[CONF_BUFFER_SIZE] = {0};
switch_size_t file_sample_len = samples; switch_size_t file_sample_len = samples;
switch_size_t file_data_len = samples * 2; switch_size_t file_data_len = samples * 2;
...@@ -654,7 +658,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v ...@@ -654,7 +658,8 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
switch_core_destroy_memory_pool(&pool); switch_core_destroy_memory_pool(&pool);
} }
} }
globals.threads--;
return NULL; return NULL;
} }
...@@ -2908,6 +2913,22 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod ...@@ -2908,6 +2913,22 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
/* Release the config registry handle */ /* Release the config registry handle */
switch_xml_free(cxml); switch_xml_free(cxml);
globals.running = 1;
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return status; return status;
} }
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
if (globals.running) {
globals.running = 0;
while (globals.threads) {
switch_yield(100000);
}
}
return SWITCH_STATUS_SUCCESS;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论