1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-04-20 02:04:54 +00:00

try to improve performance of subscribe sip handler

Conflicts:
	src/mod/endpoints/mod_sofia/sofia_presence.c
This commit is contained in:
Anthony Minessale 2013-11-13 21:41:37 +05:00
parent 51a845e37d
commit 487e1837c1
2 changed files with 8 additions and 8 deletions
src/mod/endpoints/mod_sofia

@ -6446,6 +6446,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
"create index sr_orig_server_host on sip_registrations (orig_server_host)",
"create index sr_orig_hostname on sip_registrations (orig_hostname)",
"create index ss_call_id on sip_subscriptions (call_id)",
"create index ss_multi on sip_subscriptions (call_id, profile_name, hostname)",
"create index ss_hostname on sip_subscriptions (hostname)",
"create index ss_network_ip on sip_subscriptions (network_ip)",
"create index ss_sip_user on sip_subscriptions (sip_user)",

@ -3575,8 +3575,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
int found_proto = 0;
const char *use_to_tag;
char to_tag[13] = "";
char buf[32] = "";
int subbed = 0;
char buf[80] = "";
if (!sip) {
return;
@ -3706,8 +3705,8 @@ void sofia_presence_handle_sip_i_subscribe(int status,
}
if ((sub_state != nua_substate_terminated)) {
sql = switch_mprintf("select count(*) from sip_subscriptions where call_id='%q' and hostname='%q' and profile_name='%q'",
call_id, mod_sofia_globals.hostname, profile->name);
sql = switch_mprintf("select call_id from sip_subscriptions where call_id='%q' and profile_name='%q' and hostname='%q'",
call_id, profile->name, mod_sofia_globals.hostname);
sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, buf, sizeof(buf));
@ -3718,7 +3717,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free(sql);
if ((subbed = atoi(buf)) > 0) {
if (!zstr(buf)) {
sub_state = nua_substate_active;
}
}
@ -3729,9 +3728,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
sql = switch_mprintf("update sip_subscriptions "
"set expires=%ld "
"where hostname='%q' and profile_name='%q' and call_id='%q' and profile_name='%q'",
(long) switch_epoch_time_now(NULL) + exp_delta, mod_sofia_globals.hostname, profile->name,
call_id, profile->name);
"where call_id='%q' and profile_name='%q' and hostname='%q'",
(long) switch_epoch_time_now(NULL) + exp_delta,
call_id, profile->name, mod_sofia_globals.hostname);
if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,