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

Freeswitch SVN anthm at freeswitch.org
Sat Mar 31 21:16:16 EDT 2007


Author: anthm
Date: Sat Mar 31 21:16:16 2007
New Revision: 4820

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Log:
make name more specific to avoid namespace bs

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Sat Mar 31 21:16:16 2007
@@ -38,7 +38,7 @@
 
 #include "mod_sofia.h"
 
-struct sofia_globals globals;
+struct mod_sofia_globals mod_sofia_globals;
 
 static switch_frame_t silence_frame = { 0 };
 static char silence_data[13] = "";
@@ -991,19 +991,19 @@
 		return SWITCH_STATUS_TERM;
 	}
 
-	memset(&globals, 0, sizeof(globals));
-	switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+	memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals));
+	switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
 
-	switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), AF_INET);
+	switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), AF_INET);
 
 	if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
 		return SWITCH_STATUS_TERM;
 	}
 
-	switch_core_hash_init(&globals.profile_hash, module_pool);
-	switch_core_hash_init(&globals.gateway_hash, module_pool);
-	switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
+	switch_core_hash_init(&mod_sofia_globals.profile_hash, module_pool);
+	switch_core_hash_init(&mod_sofia_globals.gateway_hash, module_pool);
+	switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
 
 	config_sofia(0);
 
@@ -1041,13 +1041,13 @@
 
 	sofia_presence_cancel();
 
-	switch_mutex_lock(globals.mutex);
-	if (globals.running == 1) {
-		globals.running = -1;
+	switch_mutex_lock(mod_sofia_globals.mutex);
+	if (mod_sofia_globals.running == 1) {
+		mod_sofia_globals.running = -1;
 	}
-	switch_mutex_unlock(globals.mutex);
+	switch_mutex_unlock(mod_sofia_globals.mutex);
 
-	while (globals.running) {
+	while (mod_sofia_globals.running) {
 		switch_yield(1000);
 	}
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Sat Mar 31 21:16:16 2007
@@ -133,7 +133,7 @@
 	TFLAG_LATE_NEGOTIATION = (1 << 24)
 } TFLAGS;
 
-struct sofia_globals {
+struct mod_sofia_globals {
 	switch_hash_t *profile_hash;
 	switch_hash_t *gateway_hash;
 	switch_mutex_t *hash_mutex;
@@ -142,7 +142,7 @@
 	switch_mutex_t *mutex;
 	char guess_ip[80];
 };
-extern struct sofia_globals globals;
+extern struct mod_sofia_globals mod_sofia_globals;
 
 
 typedef enum {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Sat Mar 31 21:16:16 2007
@@ -359,7 +359,7 @@
 		sofia_presence_establish_presence(profile);
 	}
 
-	while (globals.running == 1) {
+	while (mod_sofia_globals.running == 1) {
 		if (++ireg_loops >= IREG_SECONDS) {
 			sofia_reg_check_expire(db, profile, time(NULL));
 			ireg_loops = 0;
@@ -387,9 +387,9 @@
 	su_root_destroy(profile->s_root);
 	pool = profile->pool;
 	switch_core_destroy_memory_pool(&pool);
-	switch_mutex_lock(globals.mutex);
-	globals.running = 0;
-	switch_mutex_unlock(globals.mutex);
+	switch_mutex_lock(mod_sofia_globals.mutex);
+	mod_sofia_globals.running = 0;
+	switch_mutex_unlock(mod_sofia_globals.mutex);
 
 	return NULL;
 }
@@ -439,9 +439,9 @@
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	sofia_profile_t *profile = NULL;
 	char url[512] = "";
-	switch_mutex_lock(globals.mutex);
-	globals.running = 1;
-	switch_mutex_unlock(globals.mutex);
+	switch_mutex_lock(mod_sofia_globals.mutex);
+	mod_sofia_globals.running = 1;
+	switch_mutex_unlock(mod_sofia_globals.mutex);
 
 	if (!reload) {
 		su_init();
@@ -531,14 +531,14 @@
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
 						}
 					} else if (!strcasecmp(var, "ext-rtp-ip")) {
-						profile->extrtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->extrtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
 					} else if (!strcasecmp(var, "rtp-ip")) {
-						profile->rtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->rtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
 					} else if (!strcasecmp(var, "sip-ip")) {
-						profile->sipip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : globals.guess_ip);
+						profile->sipip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
 					} else if (!strcasecmp(var, "ext-sip-ip")) {
 						if (!strcasecmp(val, "auto")) {
-							profile->extsipip = switch_core_strdup(profile->pool, globals.guess_ip);
+							profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
 						} else {
 							char *ip = NULL;
 							switch_port_t port = 0;
@@ -625,11 +625,11 @@
 				}
 
 				if (!profile->sipip) {
-					profile->sipip = switch_core_strdup(profile->pool, globals.guess_ip);
+					profile->sipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
 				}
 
 				if (!profile->rtpip) {
-					profile->rtpip = switch_core_strdup(profile->pool, globals.guess_ip);
+					profile->rtpip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
 				}
 
 				if (profile->nonce_ttl < 60) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Sat Mar 31 21:16:16 2007
@@ -1071,18 +1071,18 @@
 {
 	sofia_profile_t *profile;
 
-	switch_mutex_lock(globals.hash_mutex);
-	profile = (sofia_profile_t *) switch_core_hash_find(globals.profile_hash, key);
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	profile = (sofia_profile_t *) switch_core_hash_find(mod_sofia_globals.profile_hash, key);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 
 	return profile;
 }
 
 void sofia_glue_add_profile(char *key, sofia_profile_t * profile)
 {
-	switch_mutex_lock(globals.hash_mutex);
-	switch_core_hash_insert(globals.profile_hash, key, profile);
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	switch_core_hash_insert(mod_sofia_globals.profile_hash, key, profile);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 }
 
 void sofia_glue_execute_sql(char *dbname, char *sql, switch_mutex_t * mutex)

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Sat Mar 31 21:16:16 2007
@@ -74,8 +74,8 @@
 	void *val;
 
 	if ((sql = switch_mprintf("select 0,'unavailable','unavailable',* from sip_subscriptions where event='presence'"))) {
-		switch_mutex_lock(globals.hash_mutex);
-		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+		switch_mutex_lock(mod_sofia_globals.hash_mutex);
+		for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			profile = (sofia_profile_t *) val;
 			if (!(profile->pflags & PFLAG_PRESENCE)) {
@@ -93,7 +93,7 @@
 		}
 		switch_safe_free(sql);
 	}
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 }
 
 void sofia_presence_establish_presence(sofia_profile_t * profile)
@@ -209,8 +209,8 @@
 			sql = switch_mprintf("select 1,'%q','%q',* from sip_subscriptions where event='presence'", status, rpid);
 		}
 
-		switch_mutex_lock(globals.hash_mutex);
-		for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+		switch_mutex_lock(mod_sofia_globals.hash_mutex);
+		for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 			switch_hash_this(hi, NULL, NULL, &val);
 			profile = (sofia_profile_t *) val;
 			if (!(profile->pflags & PFLAG_PRESENCE)) {
@@ -229,7 +229,7 @@
 			}
 
 		}
-		switch_mutex_unlock(globals.hash_mutex);
+		switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 
 		return;
 	}
@@ -315,8 +315,8 @@
 		break;
 	}
 
-	switch_mutex_lock(globals.hash_mutex);
-	for (hi = switch_hash_first(switch_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
 		switch_hash_this(hi, NULL, NULL, &val);
 		profile = (sofia_profile_t *) val;
 		if (!(profile->pflags & PFLAG_PRESENCE)) {
@@ -335,7 +335,7 @@
 			switch_core_db_close(db);
 		}
 	}
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 
 	switch_safe_free(sql);
 	switch_safe_free(user);

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	Sat Mar 31 21:16:16 2007
@@ -772,18 +772,18 @@
 {
 	outbound_reg_t *gateway;
 
-	switch_mutex_lock(globals.hash_mutex);
-	gateway = (outbound_reg_t *) switch_core_hash_find(globals.gateway_hash, key);
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	gateway = (outbound_reg_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 
 	return gateway;
 }
 
 void sofia_reg_add_gateway(char *key, outbound_reg_t * gateway)
 {
-	switch_mutex_lock(globals.hash_mutex);
-	switch_core_hash_insert(globals.gateway_hash, key, gateway);
-	switch_mutex_unlock(globals.hash_mutex);
+	switch_mutex_lock(mod_sofia_globals.hash_mutex);
+	switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
+	switch_mutex_unlock(mod_sofia_globals.hash_mutex);
 }
 
 



More information about the Freeswitch-svn mailing list