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

FreeSWITCH SVN anthm at freeswitch.org
Tue Dec 16 12:59:00 PST 2008


Author: anthm
Date: Tue Dec 16 15:59:00 2008
New Revision: 10828

Log:
fix potential race

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

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 Dec 16 15:59:00 2008
@@ -373,6 +373,8 @@
 		switch_safe_free(stream.data);
 	}
 
+	switch_clear_flag(tech_pvt, TFLAG_IO);
+
 	if (tech_pvt->read_codec.implementation) {
 		switch_core_codec_destroy(&tech_pvt->read_codec);
 	}
@@ -385,7 +387,6 @@
 	switch_core_session_unset_write_codec(session);
 
 	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);
 
@@ -656,6 +657,10 @@
 	tech_pvt->read_frame.datalen = 0;
 	switch_set_flag_locked(tech_pvt, TFLAG_READING);
 
+	if (switch_test_flag(tech_pvt, TFLAG_HUP) || switch_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	if (switch_test_flag(tech_pvt, TFLAG_IO)) {
 		switch_status_t status;
 
@@ -665,7 +670,7 @@
 
 		switch_assert(tech_pvt->rtp_session != NULL);
 		tech_pvt->read_frame.datalen = 0;
-
+		
 		while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
 			tech_pvt->read_frame.flags = SFF_NONE;
 
@@ -845,6 +850,10 @@
 		return SWITCH_STATUS_SUCCESS;
 	}
 
+	if (switch_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+		return SWITCH_STATUS_FALSE;
+	}
+
 	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
 	if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {



More information about the Freeswitch-svn mailing list