]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak
authorAnthony Minessale <anthony.minessale@gmail.com>
Sun, 24 Aug 2008 01:52:27 +0000 (01:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sun, 24 Aug 2008 01:52:27 +0000 (01:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9361 d0543943-73ff-0310-b7d9-9358b9ac24b2

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/formats/mod_local_stream/mod_local_stream.c
src/switch_loadable_module.c

index e8618ba82a731d46d4070d43974362a4ed49f928..c882e58005d8c5ae13f795cb0b717fb0c57eb1fe 100644 (file)
@@ -2226,8 +2226,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
        mod_sofia_globals.running = 1;
        switch_mutex_unlock(mod_sofia_globals.mutex);
 
-       switch_queue_create(&mod_sofia_globals.presence_queue, 500000, mod_sofia_globals.pool);
-       switch_queue_create(&mod_sofia_globals.mwi_queue, 500000, mod_sofia_globals.pool);
+       switch_queue_create(&mod_sofia_globals.presence_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
+       switch_queue_create(&mod_sofia_globals.mwi_queue, SOFIA_QUEUE_SIZE, mod_sofia_globals.pool);
 
        if (config_sofia(0, NULL) != SWITCH_STATUS_SUCCESS) {
                mod_sofia_globals.running = 0;
index 6b342d5aba728c00f092ba67673bdff7fcb1c1ae..b3b0e756a24639ed9d2ab60b9248696d2b55588d 100644 (file)
@@ -38,7 +38,7 @@
 /*************************************************************************************************************************************************************/
 #define IREG_SECONDS 30
 #define GATEWAY_SECONDS 1
-
+#define SOFIA_QUEUE_SIZE 50000
 #define HAVE_APR
 #include <switch.h>
 #include <switch_version.h>
index cc9364741b6f130d294b86a6dd004bd465bb790b..8fdb2374fb36b398d610c33fe1eb9ad7abb92a22 100644 (file)
@@ -358,7 +358,6 @@ void sofia_event_callback(nua_event_t event,
                        nua_handle_bind(nh, NULL);
                }
                sofia_private->destroy_me = 12;
-
                free(sofia_private);
                sofia_private = NULL;
        }
@@ -443,7 +442,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
 
        sofia_set_pflag_locked(profile, PFLAG_WORKER_RUNNING);
 
-       switch_queue_create(&profile->sql_queue, 500000, profile->pool);
+       switch_queue_create(&profile->sql_queue, SOFIA_QUEUE_SIZE, profile->pool);
 
        qsize = switch_queue_size(profile->sql_queue);
 
index ffb1da6a459196b47a4185b989c879198d2b545f..e31774146b429c58bc21782892b41504eb0fa25d 100644 (file)
@@ -87,7 +87,8 @@ static int do_rand(void)
 {
        double r;
        int index;
-       srand(getpid() + ++S);
+       unsigned int seed = ++S + getpid();
+       srand(seed);
        r = ((double) rand() / ((double) (RAND_MAX) + (double) (1)));
        index = (int) (r * 9) + 1;
        return index;
@@ -230,7 +231,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                        }
 
                        switch_core_timer_destroy(&timer);
-                       if (source->shuffle) {
+                       if (RUNNING && source->shuffle) {
                                skip = do_rand();
                        }
                }
@@ -472,6 +473,11 @@ static void launch_threads(void)
        switch_xml_free(xml);
 }
 
+static void event_handler(switch_event_t *event)
+{
+       RUNNING = 0;
+}
+
 SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
 {
        switch_file_interface_t *file_interface;
@@ -485,6 +491,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
        file_interface->file_close = local_stream_file_close;
        file_interface->file_read = local_stream_file_read;
 
+       if (switch_event_bind(modname, SWITCH_EVENT_SHUTDOWN, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n");
+       }
+
        memset(&globals, 0, sizeof(globals));
        switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool);
        switch_core_hash_init(&globals.source_hash, pool);
index cd0bd049330a7c2f7f0d9d1dc579fae2c4517a20..b93bfb8226b8b6bd773ec1010e6ba5436c88dbf6 100644 (file)
@@ -1149,6 +1149,8 @@ SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
                }
        }
 
+       switch_yield(1000000);
+
        for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
                switch_hash_this(hi, NULL, NULL, &val);
                module = (switch_loadable_module_t *) val;