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;
/*************************************************************************************************************************************************************/
#define IREG_SECONDS 30
#define GATEWAY_SECONDS 1
-
+#define SOFIA_QUEUE_SIZE 50000
#define HAVE_APR
#include <switch.h>
#include <switch_version.h>
nua_handle_bind(nh, NULL);
}
sofia_private->destroy_me = 12;
-
free(sofia_private);
sofia_private = NULL;
}
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);
{
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;
}
switch_core_timer_destroy(&timer);
- if (source->shuffle) {
+ if (RUNNING && source->shuffle) {
skip = do_rand();
}
}
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;
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);
}
}
+ 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;