From: Anthony Minessale Date: Mon, 18 Feb 2013 18:58:33 +0000 (-0600) Subject: cleanup X-Git-Tag: v1.3.13~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18cd797065b894b55874e499312e9fde470fdd25;p=thirdparty%2Ffreeswitch.git cleanup --- diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 90837150d4..b5e4190fef 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5886,7 +5886,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) { int sanity = 0; int i; - + switch_status_t st; switch_console_del_complete_func("::sofia::list_profiles"); switch_console_set_complete("del sofia"); @@ -5903,6 +5903,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) switch_event_unbind_callback(event_handler); switch_queue_push(mod_sofia_globals.presence_queue, NULL); + switch_queue_interrupt_all(mod_sofia_globals.presence_queue); while (mod_sofia_globals.threads) { switch_cond_next(); @@ -5914,14 +5915,17 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) for (i = 0; mod_sofia_globals.msg_queue_thread[i]; i++) { switch_queue_push(mod_sofia_globals.msg_queue, NULL); + switch_queue_interrupt_all(mod_sofia_globals.msg_queue); } for (i = 0; mod_sofia_globals.msg_queue_thread[i]; i++) { - switch_status_t st; switch_thread_join(&st, mod_sofia_globals.msg_queue_thread[i]); } + if (mod_sofia_globals.presence_thread) { + switch_thread_join(&st, mod_sofia_globals.presence_thread); + } //switch_yield(1000000); su_deinit(); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index bb09f2d95c..468473cc0e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -391,6 +391,7 @@ struct mod_sofia_globals { char *capture_server; int rewrite_multicasted_fs_path; int presence_flush; + switch_thread_t *presence_thread; }; extern struct mod_sofia_globals mod_sofia_globals; @@ -698,6 +699,7 @@ struct sofia_profile { sofia_paid_type_t paid_type; uint32_t rtp_digit_delay; switch_queue_t *event_queue; + switch_thread_t *thread; }; struct private_object { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 9630522fff..60ab5e49ec 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2660,14 +2660,14 @@ void sofia_profile_destroy(sofia_profile_t *profile) void launch_sofia_profile_thread(sofia_profile_t *profile) { - switch_thread_t *thread; + //switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; switch_threadattr_create(&thd_attr, profile->pool); switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME); - switch_thread_create(&thread, thd_attr, sofia_profile_thread_run, profile, profile->pool); + switch_thread_create(&profile->thread, thd_attr, sofia_profile_thread_run, profile, profile->pool); } static void logger(void *logarg, char const *fmt, va_list ap) @@ -3415,7 +3415,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } mod_sofia_globals.auto_restart = SWITCH_TRUE; - mod_sofia_globals.reg_deny_binding_fetch_and_no_lookup = SWITCH_FALSE; /* handle backwards compatilibity - by default use new behavior */ + mod_sofia_globals.reg_deny_binding_fetch_and_no_lookup = SWITCH_TRUE; /* handle backwards compatilibity - by default use new behavior */ mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE; if ((settings = switch_xml_child(cfg, "global_settings"))) { diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 0d4e3bb0b9..4ad83e6157 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -376,11 +376,13 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) switch_safe_free(dup_dest); switch_safe_free(remote_host); } - - switch_console_free_matches(&list); end: - + + if (list) { + switch_console_free_matches(&list); + } + switch_safe_free(contact); switch_safe_free(route_uri); switch_safe_free(ffrom); @@ -1625,7 +1627,7 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread void sofia_presence_event_thread_start(void) { - switch_thread_t *thread; + //switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; int done = 0; @@ -1642,10 +1644,10 @@ void sofia_presence_event_thread_start(void) } switch_threadattr_create(&thd_attr, mod_sofia_globals.pool); - switch_threadattr_detach_set(thd_attr, 1); + //switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_priority_set(thd_attr, SWITCH_PRI_IMPORTANT); - switch_thread_create(&thread, thd_attr, sofia_presence_event_thread_run, NULL, mod_sofia_globals.pool); + switch_thread_create(&mod_sofia_globals.presence_thread, thd_attr, sofia_presence_event_thread_run, NULL, mod_sofia_globals.pool); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index a7a72949c7..4f08924919 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -921,6 +921,10 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c switch_safe_free(sql); + if (cbt.list) { + switch_console_free_matches(&cbt.list); + } + if (cbt.matches) { return val; } else { @@ -1049,6 +1053,7 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char } else { last = switch_core_alloc(profile->pool, sizeof(*last)); *last = now; + switch_core_hash_insert(profile->mwi_debounce_hash, key, last); r = 1; } @@ -1652,8 +1657,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); } - - if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-user", to_user); diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index aedceaf435..48eb305234 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -597,11 +597,17 @@ void switch_core_memory_stop(void) { #ifndef INSTANTLY_DESTROY_POOLS switch_status_t st; + void *pop = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n"); memory_manager.pool_thread_running = 0; switch_thread_join(&st, pool_thread_p); + + + while (switch_queue_trypop(memory_manager.pool_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) { + apr_pool_destroy(pop); + } #endif } diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 9f44704190..e4cf71dc5e 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -1392,10 +1392,15 @@ SWITCH_DECLARE(int) switch_sql_queue_manager_size(switch_sql_queue_manager_t *qm SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_stop(switch_sql_queue_manager_t *qm) { switch_status_t status = SWITCH_STATUS_FALSE; + int i; if (qm->thread_running) { qm->thread_running = 0; - switch_queue_push(qm->sql_queue[0], NULL); + + for(i = 0; i < qm->numq; i++) { + switch_queue_push(qm->sql_queue[i], NULL); + switch_queue_interrupt_all(qm->sql_queue[i]); + } qm_wake(qm); status = SWITCH_STATUS_SUCCESS; }