[Freeswitch-svn] [commit] r3948 - freeswitch/trunk/src/mod/applications/mod_conference

Freeswitch SVN anthm at freeswitch.org
Thu Jan 11 19:09:43 EST 2007


Author: anthm
Date: Thu Jan 11 19:09:43 2007
New Revision: 3948

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
Avoiding Deadlock (by puting the mutex in the right place)

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Thu Jan 11 19:09:43 2007
@@ -466,15 +466,17 @@
     assert(member != NULL);
 
     switch_mutex_lock(conference->mutex);
-    switch_thread_rwlock_wrlock(conference->member_rwlock);
     switch_mutex_lock(member->audio_in_mutex);
     switch_mutex_lock(member->audio_out_mutex);
     switch_mutex_lock(member->flag_mutex);
+    
+    switch_thread_rwlock_wrlock(conference->member_rwlock);
     member->conference = conference;
     member->next = conference->members;
     member->energy_level = conference->energy_level;
     conference->members = member;
     switch_set_flag(member, MFLAG_INTREE);
+    switch_thread_rwlock_unlock(conference->member_rwlock);
 
     if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
         conference->count++;
@@ -513,7 +515,7 @@
     switch_mutex_unlock(member->flag_mutex);
     switch_mutex_unlock(member->audio_out_mutex);
     switch_mutex_unlock(member->audio_in_mutex);
-    switch_thread_rwlock_unlock(conference->member_rwlock);
+
     switch_mutex_unlock(conference->mutex);
     status = SWITCH_STATUS_SUCCESS;
 	
@@ -607,11 +609,10 @@
             switch_event_fire(&event);
         }
     }
-
+    switch_thread_rwlock_unlock(conference->member_rwlock);
     switch_mutex_unlock(member->flag_mutex);
     switch_mutex_unlock(member->audio_out_mutex);
     switch_mutex_unlock(member->audio_in_mutex);
-    switch_thread_rwlock_unlock(conference->member_rwlock);
     switch_mutex_unlock(conference->mutex);
     status = SWITCH_STATUS_SUCCESS;
 	
@@ -784,6 +785,7 @@
 					}
 				}
 			}
+            switch_thread_rwlock_unlock(conference->member_rwlock);
 
 			/* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */
 			for (imember = conference->members; imember; imember = imember->next) {
@@ -792,7 +794,6 @@
 				switch_mutex_unlock(imember->audio_out_mutex);
 			}
 		}
-        switch_thread_rwlock_unlock(conference->member_rwlock);
 
 		if (conference->fnode && conference->fnode->done) {
 			conference_file_node_t *fnode;



More information about the Freeswitch-svn mailing list