switch_bool_t reserve_agents;
switch_bool_t truncate_tiers;
switch_bool_t truncate_agents;
+ switch_bool_t global_database_lock;
int32_t threads;
int32_t running;
switch_mutex_t *mutex;
switch_cache_db_handle_t *dbh = NULL;
- if (mutex) {
- switch_mutex_lock(mutex);
- } else {
- switch_mutex_lock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_lock(mutex);
+ } else {
+ switch_mutex_lock(globals.mutex);
+ }
}
if (!(dbh = cc_get_db_handle())) {
end:
switch_cache_db_release_db_handle(&dbh);
- if (mutex) {
- switch_mutex_unlock(mutex);
- } else {
- switch_mutex_unlock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ } else {
+ switch_mutex_unlock(globals.mutex);
+ }
}
return ret;
switch_cache_db_handle_t *dbh = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- if (mutex) {
- switch_mutex_lock(mutex);
- } else {
- switch_mutex_lock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_lock(mutex);
+ } else {
+ switch_mutex_lock(globals.mutex);
+ }
}
if (!(dbh = cc_get_db_handle())) {
switch_cache_db_release_db_handle(&dbh);
- if (mutex) {
- switch_mutex_unlock(mutex);
- } else {
- switch_mutex_unlock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ } else {
+ switch_mutex_unlock(globals.mutex);
+ }
}
return status;
char *errmsg = NULL;
switch_cache_db_handle_t *dbh = NULL;
- if (mutex) {
- switch_mutex_lock(mutex);
- } else {
- switch_mutex_lock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_lock(mutex);
+ } else {
+ switch_mutex_lock(globals.mutex);
+ }
}
if (!(dbh = cc_get_db_handle())) {
switch_cache_db_release_db_handle(&dbh);
- if (mutex) {
- switch_mutex_unlock(mutex);
- } else {
- switch_mutex_unlock(globals.mutex);
+ if (globals.global_database_lock) {
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ } else {
+ switch_mutex_unlock(globals.mutex);
+ }
}
return ret;
switch_mutex_lock(globals.mutex);
globals.core_uuid = switch_core_get_uuid();
+ globals.global_database_lock = SWITCH_TRUE;
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
globals.truncate_tiers = switch_true(val);
} else if (!strcasecmp(var, "truncate-agents-on-load")) {
globals.truncate_agents = switch_true(val);
+ } else if (!strcasecmp(var, "global-database-lock")) {
+ globals.global_database_lock = switch_true(val);
}
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reserving Agents before offering calls.\n");
}
+
+ if (!globals.global_database_lock) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Disabling global database lock\n");
+ }
+
/* Initialize database */
if (!(dbh = cc_get_db_handle())) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!\n");