{
switch_cache_db_handle_t *dbh = NULL;
- if (mutex) {
- switch_mutex_lock(mutex);
- }
-
if (!(dbh = sofia_glue_get_db_handle(profile))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
+ return;
}
- switch_cache_db_persistant_execute_trans(dbh, sql, 1);
+ if (mutex) {
+ switch_mutex_lock(mutex);
+ }
- end:
+ switch_cache_db_persistant_execute_trans(dbh, sql, 1);
switch_cache_db_release_db_handle(&dbh);
switch_cache_db_handle_t *dbh = NULL;
char *err = NULL;
- if (mutex) {
- switch_mutex_lock(mutex);
- }
-
if (!(dbh = sofia_glue_get_db_handle(profile))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
+ return;
+ }
+
+ if (mutex) {
+ switch_mutex_lock(mutex);
}
switch_cache_db_execute_sql(dbh, sql, &err);
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ }
+
if (err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s]\n%s\n", err, sql);
free(err);
}
- end:
-
switch_cache_db_release_db_handle(&dbh);
-
- if (mutex) {
- switch_mutex_unlock(mutex);
- }
}
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
char *errmsg = NULL;
switch_cache_db_handle_t *dbh = NULL;
- if (mutex) {
- switch_mutex_lock(mutex);
- }
-
if (!(dbh = sofia_glue_get_db_handle(profile))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
+ return ret;
+ }
+
+ if (mutex) {
+ switch_mutex_lock(mutex);
}
switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ }
+
if (errmsg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
free(errmsg);
}
- end:
-
switch_cache_db_release_db_handle(&dbh);
- if (mutex) {
- switch_mutex_unlock(mutex);
- }
-
return ret;
}
ret = switch_cache_db_execute_sql2str(dbh, sql, resbuf, len, &err);
+ if (mutex) {
+ switch_mutex_unlock(mutex);
+ }
+
if (err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s]\n%s\n", err, sql);
free(err);
}
- if (mutex) {
- switch_mutex_unlock(mutex);
- }
-
switch_cache_db_release_db_handle(&dbh);
return ret;
",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where call_id='%q' %s", reboot, call_id, sqlextra);
- switch_mutex_lock(profile->ireg_mutex);
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
- switch_mutex_unlock(profile->ireg_mutex);
+
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_del_callback, profile);
switch_safe_free(sql);
sql = switch_mprintf("delete from sip_registrations where call_id='%q' %s", call_id, sqlextra);
{
char sql[1024];
- switch_mutex_lock(profile->ireg_mutex);
+
if (now) {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires"
",user_agent,server_user,server_host,profile_name,network_ip" ",%d from sip_registrations where expires > 0", reboot);
}
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_del_callback, profile);
if (now) {
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%q'",
(long) now, mod_sofia_globals.hostname);
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
}
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_snprintfv(sql, sizeof(sql), "select call_id from sip_shared_appearance_dialogs where hostname='%q' "
"and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile);
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_sla_dialog_del_callback, profile);
switch_snprintfv(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%q' and expires <= %ld",
mod_sofia_globals.hostname, (long) now);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
}
switch_snprintfv(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
}
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
if (now) {
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%q'",
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
}
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
sofia_presence_check_subscriptions(profile, now);
switch_snprintfv(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
}
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
if (now) {
" from sip_registrations where hostname='%s' and "
"profile_name='%s'", mod_sofia_globals.hostname, profile->name);
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nat_callback, profile);
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nat_callback, profile);
} else if (sofia_test_pflag(profile, PFLAG_NAT_OPTIONS_PING)) {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name"
"or contact like '%%fs_nat=yes%%') and hostname='%s' "
"and profile_name='%s'", mod_sofia_globals.hostname, profile->name);
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nat_callback, profile);
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_nat_callback, profile);
}
}
- switch_mutex_unlock(profile->ireg_mutex);
-
}
",user_agent,server_user,server_host,profile_name,network_ip"
" from sip_registrations where call_id='%q' %s", call_id, sqlextra);
- switch_mutex_lock(profile->ireg_mutex);
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_check_callback, profile);
- switch_mutex_unlock(profile->ireg_mutex);
+
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_check_callback, profile);
+
switch_safe_free(sql);
switch_safe_free(sqlextra);
{
char sql[1024];
- switch_mutex_lock(profile->ireg_mutex);
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires"
",user_agent,server_user,server_host,profile_name,network_ip"
" from sip_registrations where expires > 0");
- sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
+ sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_reg_del_callback, profile);
switch_snprintfv(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_snprintfv(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_snprintfv(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%q'", mod_sofia_globals.hostname);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_snprintfv(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_snprintfv(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%q'", mod_sofia_globals.hostname);
- sofia_glue_actually_execute_sql(profile, sql, NULL);
-
- switch_mutex_unlock(profile->ireg_mutex);
+ sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
}
} else {
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host);
}
- switch_mutex_lock(profile->ireg_mutex);
+
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
} else {
char buf[32] = "";
sql = switch_mprintf("select count(*) from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
- switch_mutex_lock(profile->ireg_mutex);
+
sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, buf, sizeof(buf));
switch_safe_free(sql);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
- switch_mutex_unlock(profile->ireg_mutex);
+
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);