]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Allow to send the flush/reboot all the registration of a domain (MODENDP-187)
authorMichael Jerris <mike@jerris.com>
Fri, 15 May 2009 19:36:43 +0000 (19:36 +0000)
committerMichael Jerris <mike@jerris.com>
Fri, 15 May 2009 19:36:43 +0000 (19:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13363 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_reg.c

index 777707e5f5a06ac1f97651b058391c4842156ffa..c2e425d2845a6c03a547399901d94894b35c7b05 100644 (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);
 
 }