[Freeswitch-svn] [commit] r7737 - in freeswitch/trunk/src: . include include/private mod/endpoints/mod_dingaling mod/endpoints/mod_iax mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Tue Feb 26 11:55:40 EST 2008


Author: anthm
Date: Tue Feb 26 11:55:40 2008
New Revision: 7737

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/switch_core_memory.c
   freeswitch/trunk/src/switch_core_rwlock.c
   freeswitch/trunk/src/switch_core_session.c

Log:
add in switch_core_signal_lock/unlock

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Tue Feb 26 11:55:40 2008
@@ -109,6 +109,7 @@
 
 	switch_mutex_t *mutex;
 	switch_mutex_t *resample_mutex;
+	switch_mutex_t *signal_mutex;
 	switch_thread_cond_t *cond;
 
 	switch_thread_rwlock_t *rwlock;

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Tue Feb 26 11:55:40 2008
@@ -286,6 +286,9 @@
 ///\ingroup core1
 ///\{
 
+SWITCH_DECLARE(switch_status_t) switch_core_session_signal_lock(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_core_session_signal_unlock(switch_core_session_t *session);
+
 #ifdef SWITCH_DEBUG_RWLOCKS
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
 #endif

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Tue Feb 26 11:55:40 2008
@@ -2538,6 +2538,8 @@
 
 
 	if ((session = ldl_session_get_private(dlsession))) {
+
+		switch_core_session_signal_lock(session);
 		tech_pvt = switch_core_session_get_private(session);
 		switch_assert(tech_pvt != NULL);
 
@@ -2559,7 +2561,7 @@
 		}
 		if ((session = switch_core_session_request(dingaling_endpoint_interface, NULL)) != 0) {
 			switch_core_session_add_stream(session, NULL);
-
+			switch_core_session_signal_lock(session);
 			
 			if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
 				char *exten;
@@ -2946,6 +2948,10 @@
 
  done:
 
+	if (session) {
+		switch_core_session_signal_unlock(session);
+	}
+
 	return status;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	Tue Feb 26 11:55:40 2008
@@ -938,6 +938,7 @@
 
 			if ((tech_pvt = iax_get_private(iaxevent->session))) {
 				channel = switch_core_session_get_channel(tech_pvt->session);
+				switch_core_session_signal_lock(tech_pvt->session);
 			}
 
 			if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
@@ -1115,6 +1116,10 @@
 				break;
 			}
 			iax_event_free(iaxevent);
+
+			if (tech_pvt && tech_pvt->session) {
+				switch_core_session_signal_unlock(tech_pvt->session);
+			}
 		}
 	}
 

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	Tue Feb 26 11:55:40 2008
@@ -708,7 +708,7 @@
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	switch_mutex_lock(tech_pvt->flag_mutex);
-
+	
 	if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) {
 		status = SWITCH_STATUS_FALSE;
 		goto end;

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	Tue Feb 26 11:55:40 2008
@@ -222,8 +222,8 @@
 						  nua_event_name(event), status, phrase, session ? switch_channel_get_name(channel) : "n/a");
 	}
 
-	if (tech_pvt) {
-		switch_mutex_lock(tech_pvt->flag_mutex);
+	if (session) {
+		switch_core_session_signal_lock(session);
 	}
 
 	if ((profile->pflags & PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip) {
@@ -352,11 +352,8 @@
 		sofia_reg_release_gateway(gateway);
 	}
 
-	if (tech_pvt) {
-		switch_mutex_unlock(tech_pvt->flag_mutex);
-	}
-
 	if (session) {
+		switch_core_session_signal_unlock(session);
 		switch_core_session_rwunlock(session);
 	}
 }

Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c	(original)
+++ freeswitch/trunk/src/switch_core_memory.c	Tue Feb 26 11:55:40 2008
@@ -35,7 +35,7 @@
 #include <switch.h>
 #include "private/switch_core_pvt.h"
 /*#define LOCK_MORE*/
-#define PER_POOL_LOCK 1
+/*#define PER_POOL_LOCK 1*/
 
 static struct {
 	switch_mutex_t *mem_lock;

Modified: freeswitch/trunk/src/switch_core_rwlock.c
==============================================================================
--- freeswitch/trunk/src/switch_core_rwlock.c	(original)
+++ freeswitch/trunk/src/switch_core_rwlock.c	Tue Feb 26 11:55:40 2008
@@ -35,6 +35,17 @@
 #include <switch.h>
 #include "private/switch_core_pvt.h"
 
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_signal_lock(switch_core_session_t *session)
+{
+	return switch_mutex_lock(session->signal_mutex);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_signal_unlock(switch_core_session_t *session)
+{
+	return switch_mutex_unlock(session->signal_mutex);
+}
+
 #ifdef SWITCH_DEBUG_RWLOCKS
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, const char *file, const char *func, int line)
 #else

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Tue Feb 26 11:55:40 2008
@@ -347,6 +347,9 @@
 		return status;
 	}
 	
+
+	switch_core_session_signal_lock(session);
+
 	if (session->endpoint_interface->io_routines->receive_message) {
 		status = session->endpoint_interface->io_routines->receive_message(session, message);
 	}
@@ -360,6 +363,9 @@
 	}
 
 	switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
+
+	switch_core_session_signal_unlock(session);
+
 	switch_core_session_rwunlock(session);
 
 	return status;
@@ -831,6 +837,7 @@
 
 	switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED, session->pool);
 	switch_mutex_init(&session->resample_mutex, SWITCH_MUTEX_NESTED, session->pool);
+	switch_mutex_init(&session->signal_mutex, SWITCH_MUTEX_NESTED, session->pool);
 	switch_thread_rwlock_create(&session->bug_rwlock, session->pool);
 	switch_thread_cond_create(&session->cond, session->pool);
 	switch_thread_rwlock_create(&session->rwlock, session->pool);



More information about the Freeswitch-svn mailing list