[Freeswitch-trunk] [commit] r3869 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Fri Dec 29 01:21:05 EST 2006


Author: anthm
Date: Fri Dec 29 01:21:04 2006
New Revision: 3869

Modified:
   freeswitch/trunk/src/switch_core.c

Log:
tweak locks

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Fri Dec 29 01:21:04 2006
@@ -548,8 +548,12 @@
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
     if (session->rwlock) {
-        status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
-	}
+        if (switch_test_flag(session, SSF_DESTROYED)) {
+            status = SWITCH_STATUS_FALSE;
+        } else {
+            status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
+        }	
+    }
 
 	return status;
 }
@@ -3241,7 +3245,6 @@
 	if (runtime.session_count) {
 		runtime.session_count--;
 	}
-    switch_set_flag((*session), SSF_DESTROYED);
 	switch_mutex_unlock(runtime.session_table_mutex);
 
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DESTROY) == SWITCH_STATUS_SUCCESS) {
@@ -3356,6 +3359,7 @@
 	switch_core_media_bug_remove_all(session);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session %u (%s) Locked, Waiting on external entities\n", session->id, switch_channel_get_name(session->channel));
 	switch_core_session_write_lock(session);
+    switch_set_flag(session, SSF_DESTROYED);
 	switch_core_session_rwunlock(session);
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Session %u (%s) Ended\n", session->id, switch_channel_get_name(session->channel));



More information about the Freeswitch-trunk mailing list