Allow to send the flush/reboot all the registration of a domain (MODENDP-187)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13363 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-05-15 19:36:43 +00:00
parent 21159328e7
commit 2ac2fa8659
1 changed files with 18 additions and 8 deletions

View File

@ -484,23 +484,33 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames
void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int reboot)
{
char sql[1024];
char sqlextra[1024] = "";
char *psql = sql;
char *user = strdup(call_id);
char *host = NULL;
char *dup = strdup(call_id);
char *host = NULL, *user = NULL;
switch_assert(user);
switch_assert(dup);
if ((host = strchr(user, '@'))) {
if ((host = strchr(dup, '@'))) {
*host++ = '\0';
user = dup;
} else {
host = dup;
}
if (!host) {
host = "none";
}
if (switch_strlen_zero(user)) {
switch_snprintf(sqlextra, sizeof(sqlextra), " or (sip_host='%s')", host);
} else {
switch_snprintf(sqlextra, sizeof(sqlextra), " or (sip_user='%s' and sip_host='%s')", user, host);
}
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name"
",%d from sip_registrations where call_id='%s' or (sip_user='%s' and sip_host='%s')",
reboot, call_id, user, host);
",%d from sip_registrations where call_id='%s' %s",
reboot, call_id, sqlextra);
switch_mutex_lock(profile->ireg_mutex);
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_del_callback, profile);
@ -510,7 +520,7 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int
call_id, user, host);
sofia_glue_execute_sql(profile, &psql, SWITCH_FALSE);
switch_safe_free(user);
switch_safe_free(dup);
}