Revision
17167
Author
mikej
Date
2010-04-01 15:15:58 -0500 (Thu, 01 Apr 2010)

Log Message

add killgw _all_ to delete all gws

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (17166 => 17167)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2010-04-01 20:15:47 UTC (rev 17166)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2010-04-01 20:15:58 UTC (rev 17167)
@@ -2604,12 +2604,17 @@
 			goto done;
 		}
 
-		if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) {
-			sofia_glue_del_gateway(gateway_ptr);
-			sofia_reg_release_gateway(gateway_ptr);
-			stream->write_function(stream, "+OK gateway marked for deletion.\n");
+		if (!strcasecmp(argv[2], "_all_")) {
+			sofia_glue_del_every_gateway(profile);
+			stream->write_function(stream, "+OK every gateway marked for deletion.\n");
 		} else {
-			stream->write_function(stream, "-ERR no such gateway.\n");
+			if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) {
+				sofia_glue_del_gateway(gateway_ptr);
+				sofia_reg_release_gateway(gateway_ptr);
+				stream->write_function(stream, "+OK gateway marked for deletion.\n");
+			} else {
+				stream->write_function(stream, "-ERR no such gateway.\n");
+			}
 		}
 
 		goto done;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (17166 => 17167)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2010-04-01 20:15:47 UTC (rev 17166)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2010-04-01 20:15:58 UTC (rev 17167)
@@ -915,6 +915,7 @@
 const char *sofia_glue_strip_proto(const char *uri);
 switch_status_t reconfig_sofia(sofia_profile_t *profile);
 void sofia_glue_del_gateway(sofia_gateway_t *gp);
+void sofia_glue_del_every_gateway(sofia_profile_t *profile);
 void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
 						   const char *network_ip);
 void sofia_glue_restart_all_profiles(void);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (17166 => 17167)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-04-01 20:15:47 UTC (rev 17166)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-04-01 20:15:58 UTC (rev 17167)
@@ -3932,6 +3932,19 @@
 	return status;
 }
 
+
+void sofia_glue_del_every_gateway(sofia_profile_t *profile)
+{
+	sofia_gateway_t *gp = NULL;
+
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	for (gp = profile->gateways; gp; gp = gp->next) {
+		sofia_glue_del_gateway(gp);
+	}
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+}
+
+
 void sofia_glue_del_gateway(sofia_gateway_t *gp)
 {
 	if (!gp->deleted) {