[Freeswitch-svn] [commit] r13363 - freeswitch/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN mikej at freeswitch.org
Fri May 15 12:36:43 PDT 2009


Author: mikej
Date: Fri May 15 14:36:43 2009
New Revision: 13363

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

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Fri May 15 14:36:43 2009
@@ -484,23 +484,33 @@
 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 @@
 					call_id, user, host);
 	sofia_glue_execute_sql(profile, &psql, SWITCH_FALSE);
 
-	switch_safe_free(user);
+	switch_safe_free(dup);
 
 }
 



More information about the Freeswitch-svn mailing list