]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cleanup
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 18 Feb 2013 18:58:33 +0000 (12:58 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 18 Feb 2013 19:54:34 +0000 (13:54 -0600)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c
src/switch_core_memory.c
src/switch_core_sqldb.c

index 90837150d41f80c6337006ecac3d9f24868f844e..b5e4190fef1e29a484aec591fd8d6236f2c39bef 100644 (file)
@@ -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();
index bb09f2d95c996aa88366127427a5a1fbda1c62f4..468473cc0e958aebd829b573e9ad3aaf55e83583 100644 (file)
@@ -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 {
index 9630522fffed334e887a199706f0270aa8d96dc8..60ab5e49ece7d90c1453491a9a38d55f21d31d17 100644 (file)
@@ -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"))) {
index 0d4e3bb0b999ff447ec8ae1a8a50f676694a66e8..4ad83e61571c252833a982e14db582b4c7921fa6 100644 (file)
@@ -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);
 }
 
 
index a7a72949c718a8349d733397aaf9d40e051d9139..4f0892491968b70ca20af01801225ebd414f08d7 100644 (file)
@@ -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);
index aedceaf435026b92de9bf79ff0e38151f7345e8a..48eb305234822fe5588ef13c9673fac43c113b7c 100644 (file)
@@ -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
 }
 
index 9f4470419025410f3e3849c0262f7950f6b44872..e4cf71dc5e35675e8fd77c01e4c15ab56f758c50 100644 (file)
@@ -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;
        }