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

Freeswitch SVN anthm at freeswitch.org
Thu Oct 30 18:40:40 EDT 2008


Author: anthm
Date: Thu Oct 30 18:40:39 2008
New Revision: 10206

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_core.h
   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/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/switch_channel.c
   freeswitch/trunk/src/switch_core_rwlock.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_state_machine.c

Log:
redo some stuff

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	Thu Oct 30 18:40:39 2008
@@ -121,7 +121,6 @@
 
 	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	Thu Oct 30 18:40:39 2008
@@ -297,9 +297,6 @@
 ///\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_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	Thu Oct 30 18:40:39 2008
@@ -938,7 +938,6 @@
 
 			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) {
@@ -1122,9 +1121,6 @@
 			}
 			iax_event_free(iaxevent);
 			switch_mutex_unlock(globals.mutex);
-			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	Thu Oct 30 18:40:39 2008
@@ -292,7 +292,7 @@
 		switch_core_session_rwunlock(a_session);
 	}
 
-	switch_mutex_lock(tech_pvt->profile->flag_mutex);
+
 
 	if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
 		char reason[128] = "";
@@ -326,6 +326,7 @@
 			switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
 		}
 
+		switch_mutex_lock(tech_pvt->sofia_mutex);
 		if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
 			if (!tech_pvt->got_bye) {
 				switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
@@ -357,10 +358,12 @@
 							TAG_END());
 			}
 		}
+		switch_mutex_unlock(tech_pvt->sofia_mutex);
 		switch_set_flag(tech_pvt, TFLAG_BYE);
 		switch_safe_free(stream.data);
 	}
 
+	switch_mutex_lock(tech_pvt->profile->flag_mutex);
 	switch_clear_flag(tech_pvt, TFLAG_IO);
 	tech_pvt->profile->inuse--;
 	switch_mutex_unlock(tech_pvt->profile->flag_mutex);
@@ -416,23 +419,21 @@
 		/* This if statement check and handles the 3pcc proxy mode */
 		if ((tech_pvt->profile->pflags & PFLAG_3PCC_PROXY) && switch_test_flag(tech_pvt, TFLAG_3PCC)) {
 			/* Send the 200 OK */
+			switch_mutex_lock(tech_pvt->sofia_mutex);
 			nua_respond(tech_pvt->nh, SIP_200_OK,
 				SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 				SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				SOATAG_REUSE_REJECTED(1),
 				SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+			switch_mutex_unlock(tech_pvt->sofia_mutex);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
 			
 			/* Unlock the session signal to allow the ack to make it in */
 			// Maybe we should timeout?
-			switch_core_session_signal_unlock(session);
+			
 			while(switch_channel_ready(channel) && !switch_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
 				switch_yield(1000);
 			}
-			// if we never got the ack should we PUNT?
-			/* Get the lock back before we continue */
-			switch_core_session_signal_lock(session);
-			
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
 		}
 
@@ -452,7 +453,9 @@
 
 				if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+					//switch_mutex_lock(tech_pvt->sofia_mutex);
 					//nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+					//switch_mutex_unlock(tech_pvt->sofia_mutex);
 					return SWITCH_STATUS_FALSE;
 				}
 			}
@@ -491,7 +494,7 @@
 	}
 
 
-
+	switch_mutex_lock(tech_pvt->sofia_mutex);
 	nua_respond(tech_pvt->nh, SIP_200_OK,
 				NUTAG_AUTOANSWER(0),
 				TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
@@ -499,7 +502,7 @@
 				SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 				SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
-
+	switch_mutex_unlock(tech_pvt->sofia_mutex);
 	switch_set_flag_locked(tech_pvt, TFLAG_ANS);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -796,7 +799,9 @@
 
 	case DTMF_INFO:
 		snprintf(message, sizeof(message), "Signal=%c\r\nDuration=%d\r\n", dtmf->digit, dtmf->duration / 8);
+		switch_mutex_lock(tech_pvt->sofia_mutex);
 		nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"), SIPTAG_PAYLOAD_STR(message), TAG_END());
+		switch_mutex_unlock(tech_pvt->sofia_mutex);
 		break;
 	default:
 		break;
@@ -831,10 +836,15 @@
 				" <media_control>\r\n"
 				"  <vc_primitive>\r\n"
 				"   <to_encoder>\r\n"
-				"    <picture_fast_update>\r\n" "    </picture_fast_update>\r\n" "   </to_encoder>\r\n" "  </vc_primitive>\r\n" " </media_control>\r\n";
+				"    <picture_fast_update>\r\n" 
+				"    </picture_fast_update>\r\n" 
+				"   </to_encoder>\r\n" 
+				"  </vc_primitive>\r\n" 
+				" </media_control>\r\n";
 
+			switch_mutex_lock(tech_pvt->sofia_mutex);
 			nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
-
+			switch_mutex_unlock(tech_pvt->sofia_mutex);
 
 		}
 		break;
@@ -851,10 +861,12 @@
 			if (ip && port) {
 				sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1);
 			}
+			switch_mutex_lock(tech_pvt->sofia_mutex);
 			nua_respond(tech_pvt->nh, SIP_200_OK,
 						SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 						SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 						SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+			switch_mutex_unlock(tech_pvt->sofia_mutex);
 			switch_channel_mark_answered(channel);
 		}
 		break;
@@ -936,7 +948,9 @@
 			if (!switch_strlen_zero(msg->string_arg)) {
 				char message[256] = "";
 				snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
+				switch_mutex_lock(tech_pvt->sofia_mutex);
 				nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
+				switch_mutex_unlock(tech_pvt->sofia_mutex);
 			}
 		}
 		break;
@@ -948,7 +962,9 @@
 			if (!switch_strlen_zero(msg->string_arg)) {
 				char message[256] = "";
 				snprintf(message, sizeof(message), "From:\r\nTo: \"%s\"\r\n", msg->string_arg);
+				switch_mutex_lock(tech_pvt->sofia_mutex);
 				nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), SIPTAG_PAYLOAD_STR(message), TAG_END());
+				switch_mutex_unlock(tech_pvt->sofia_mutex);
 			}
 		}
 		break;
@@ -1007,7 +1023,9 @@
 		if (!switch_strlen_zero(msg->string_arg)) {
 			if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting to %s\n", msg->string_arg);
+				switch_mutex_lock(tech_pvt->sofia_mutex);
 				nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
+				switch_mutex_unlock(tech_pvt->sofia_mutex);
 				switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Too late for redirecting to %s, already answered\n", msg->string_arg);
@@ -1024,8 +1042,9 @@
 			} else {
 				switch_set_string(ref_to, msg->string_arg);
 			}
-
+			switch_mutex_lock(tech_pvt->sofia_mutex);
 			nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(tech_pvt->contact_url), TAG_END());
+			switch_mutex_unlock(tech_pvt->sofia_mutex);
 		}
 		break;
 
@@ -1082,9 +1101,11 @@
 				}
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason);
+				switch_mutex_lock(tech_pvt->sofia_mutex);
 				nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)),
 							SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
 							TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
+				switch_mutex_unlock(tech_pvt->sofia_mutex);
 				if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
 					switch_set_flag_locked(tech_pvt, TFLAG_BYE);
 				}
@@ -1104,12 +1125,16 @@
 						sofia_glue_tech_patch_sdp(tech_pvt);
 						sofia_glue_tech_proxy_remote_addr(tech_pvt);
 					}
+					switch_mutex_lock(tech_pvt->sofia_mutex);
 					nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 								SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 								SOATAG_REUSE_REJECTED(1),
 								SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+					switch_mutex_unlock(tech_pvt->sofia_mutex);
 				} else {
+					switch_mutex_lock(tech_pvt->sofia_mutex);
 					nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
+					switch_mutex_unlock(tech_pvt->sofia_mutex);
 				}
 				if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) {
 					switch_set_flag_locked(tech_pvt, TFLAG_BYE);
@@ -1121,7 +1146,9 @@
 	case SWITCH_MESSAGE_INDICATE_RINGING:
 		if (!switch_channel_test_flag(channel, CF_RING_READY) &&
 			!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
+			switch_mutex_lock(tech_pvt->sofia_mutex);
 			nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
+			switch_mutex_unlock(tech_pvt->sofia_mutex);
 			switch_channel_mark_ring_ready(channel);
 		}
 		break;
@@ -1161,7 +1188,9 @@
 							sofia_glue_tech_prepare_codecs(tech_pvt);
 							if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
 								switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+								//switch_mutex_lock(tech_pvt->sofia_mutex);
 								//nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+								//switch_mutex_unlock(tech_pvt->sofia_mutex);
 								status = SWITCH_STATUS_FALSE;
 								goto end;
 							}
@@ -1190,6 +1219,7 @@
 					switch_channel_set_variable(channel, "sip_nat_detected", "true");
 				}
 
+				switch_mutex_lock(tech_pvt->sofia_mutex);
 				nua_respond(tech_pvt->nh,
 							SIP_183_SESSION_PROGRESS,
 							NUTAG_AUTOANSWER(0),
@@ -1199,6 +1229,7 @@
 							SOATAG_ORDERED_USER(1),
 							SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
 							SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END());
+				switch_mutex_unlock(tech_pvt->sofia_mutex);
 			}
 		}
 		break;
@@ -1225,11 +1256,13 @@
 	}
 
 	if (tech_pvt->hash_key) {
+		switch_mutex_lock(tech_pvt->sofia_mutex);
 		msg_nh = nua_handle(tech_pvt->profile->nua, NULL,
 							SIPTAG_FROM_STR(tech_pvt->chat_from),
 							NUTAG_URL(tech_pvt->chat_to), SIPTAG_TO_STR(tech_pvt->chat_to), SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END());
 		nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
 		nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
+		switch_mutex_unlock(tech_pvt->sofia_mutex);
 	}
 
 	return SWITCH_STATUS_SUCCESS;
@@ -1946,6 +1979,7 @@
 		goto error;
 	}
 	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
+	switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(nsession));
 
 	data = switch_core_session_strdup(nsession, outbound_profile->destination_number);
 	if ((dest_to = strchr(data, '^'))) {

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	Thu Oct 30 18:40:39 2008
@@ -467,6 +467,7 @@
 	unsigned long rm_rate;
 	switch_payload_t pt;
 	switch_mutex_t *flag_mutex;
+	switch_mutex_t *sofia_mutex;
 	switch_payload_t te;
 	switch_payload_t bte;
 	switch_payload_t cng_pt;

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	Thu Oct 30 18:40:39 2008
@@ -180,6 +180,7 @@
 		} else if (!switch_strlen_zero(sofia_private->uuid)) {
 			if ((session = switch_core_session_locate(sofia_private->uuid))) {
 				tech_pvt = switch_core_session_get_private(session);
+				switch_assert(tech_pvt);
 				channel = switch_core_session_get_channel(tech_pvt->session);
 				if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
 					tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id);
@@ -196,7 +197,7 @@
 	}
 
 	if (session) {
-		switch_core_session_signal_lock(session);
+		switch_mutex_lock(tech_pvt->sofia_mutex);
 
 		if (channel && switch_channel_get_state(channel) >= CS_HANGUP) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already hungup.\n");
@@ -353,7 +354,7 @@
 	}
 
 	if (session) {
-		switch_core_session_signal_unlock(session);
+		switch_mutex_unlock(tech_pvt->sofia_mutex);
 		switch_core_session_rwunlock(session);
 	}
 }
@@ -3486,6 +3487,7 @@
 
 
 	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+	switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 
 	tech_pvt->remote_ip = switch_core_session_strdup(session, network_ip);
 	tech_pvt->remote_port = network_port;

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	Thu Oct 30 18:40:39 2008
@@ -1702,9 +1702,7 @@
 	const char *var;
 
 	switch_assert(tech_pvt != NULL);
-
-	switch_core_session_signal_lock(tech_pvt->session);
-
+	switch_mutex_lock(tech_pvt->sofia_mutex);
 
 	if ((var = switch_channel_get_variable(tech_pvt->channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
 		switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
@@ -2027,7 +2025,7 @@
 
   end:
 
-	switch_core_session_signal_unlock(tech_pvt->session);
+	switch_mutex_unlock(tech_pvt->sofia_mutex);
 
 	return status;
 

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Thu Oct 30 18:40:39 2008
@@ -390,7 +390,9 @@
 {
 	switch_channel_flush_dtmf(channel);
 	switch_core_hash_destroy(&channel->private_hash);
+	switch_mutex_lock(channel->profile_mutex);
 	switch_event_destroy(&channel->variables);
+	switch_mutex_unlock(channel->profile_mutex);
 }
 
 SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, switch_core_session_t *session, switch_channel_state_t state,
@@ -562,7 +564,7 @@
 {
 	switch_assert(channel != NULL);
 
-	if (!switch_strlen_zero(varname)) {
+	if (channel->variables && !switch_strlen_zero(varname)) {
 		switch_mutex_lock(channel->profile_mutex);
 		switch_event_del_header(channel->variables, varname);
 		if (!switch_strlen_zero(value)) {
@@ -584,7 +586,7 @@
 	va_list ap;
 	switch_assert(channel != NULL);
 
-	if (!switch_strlen_zero(varname)) {
+	if (channel->variables && !switch_strlen_zero(varname)) {
 		switch_mutex_lock(channel->profile_mutex);
 		switch_event_del_header(channel->variables, varname);
 

Modified: freeswitch/trunk/src/switch_core_rwlock.c
==============================================================================
--- freeswitch/trunk/src/switch_core_rwlock.c	(original)
+++ freeswitch/trunk/src/switch_core_rwlock.c	Thu Oct 30 18:40:39 2008
@@ -35,15 +35,6 @@
 #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)

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Thu Oct 30 18:40:39 2008
@@ -57,9 +57,10 @@
 		if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
 			/* Acquire a read lock on the session */
 #ifdef SWITCH_DEBUG_RWLOCKS
-			if (switch_core_session_perform_read_lock(session, file, func, line) != SWITCH_STATUS_SUCCESS) {
+			if (switch_channel_get_state(session->channel) >= CS_HANGUP || 
+				switch_core_session_perform_read_lock(session, file, func, line) != SWITCH_STATUS_SUCCESS) {
 #else
-			if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+			if (switch_channel_get_state(session->channel) >= CS_HANGUP || switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
 #endif
 				/* not available, forget it */
 				session = NULL;
@@ -418,8 +419,6 @@
 		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);
 	}
@@ -433,9 +432,6 @@
 	}
 
 	switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
-
-	switch_core_session_signal_unlock(session);
-
 	switch_core_session_rwunlock(session);
 
 	return status;
@@ -988,7 +984,6 @@
 
 	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);

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Thu Oct 30 18:40:39 2008
@@ -396,9 +396,8 @@
 							do_extra_handlers = 0;
 						}
 					}
-					switch_core_session_signal_lock(session);
+					
 					STATE_MACRO(hangup, "HANGUP");
-					switch_core_session_signal_unlock(session);
 
 					hook_var = switch_channel_get_variable(session->channel, SWITCH_API_HANGUP_HOOK_VARIABLE);
 
@@ -418,19 +417,13 @@
 				}
 				goto done;
 			case CS_INIT:		/* Basic setup tasks */
-				switch_core_session_signal_lock(session);
 				STATE_MACRO(init, "INIT");
-				switch_core_session_signal_unlock(session);
 				break;
 			case CS_ROUTING:	/* Look for a dialplan and find something to do */
-				switch_core_session_signal_lock(session);
 				STATE_MACRO(routing, "ROUTING");
-				switch_core_session_signal_unlock(session);
 				break;
 			case CS_RESET:		/* Reset */
-				switch_core_session_signal_lock(session);
 				STATE_MACRO(reset, "RESET");
-				switch_core_session_signal_unlock(session);
 				break;
 				/* These other states are intended for prolonged durations so we do not signal lock for them */
 			case CS_EXECUTE:	/* Execute an Operation */



More information about the Freeswitch-svn mailing list