[asterisk-commits] file: branch file/bridging r177981 - /team/file/bridging/bridges/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 21 22:08:56 CST 2009


Author: file
Date: Sat Feb 21 22:08:55 2009
New Revision: 177981

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=177981
Log:
Wait until the thread servicing the multiplexed thread structure actually exits before returning. This prevents a scenario where adding/removing a channel fast makes the thread go away without another taking its place.

Modified:
    team/file/bridging/bridges/bridge_multiplexed.c

Modified: team/file/bridging/bridges/bridge_multiplexed.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/bridging/bridges/bridge_multiplexed.c?view=diff&rev=177981&r1=177980&r2=177981
==============================================================================
--- team/file/bridging/bridges/bridge_multiplexed.c (original)
+++ team/file/bridging/bridges/bridge_multiplexed.c Sat Feb 21 22:08:55 2009
@@ -187,6 +187,7 @@
 static void multiplexed_add_or_remove(struct multiplexed_thread *multiplexed_thread, struct ast_channel *chan, int add)
 {
 	int i, removed = 0;
+	pthread_t thread = AST_PTHREADT_NULL;
 
 	ao2_lock(multiplexed_thread);
 
@@ -214,12 +215,17 @@
 			ast_debug(1, "Failed to create an actual thread for multiplexed thread '%p', trying next time\n", multiplexed_thread);
 		}
 	} else if (!multiplexed_thread->service_count && multiplexed_thread->thread != AST_PTHREADT_NULL) {
+		thread = multiplexed_thread->thread;
 		multiplexed_thread->thread = AST_PTHREADT_STOP;
 	} else if (!add && removed) {
 		memmove(multiplexed_thread->chans + i, multiplexed_thread->chans + i + 1, sizeof(struct ast_channel *) * (MULTIPLEXED_MAX_CHANNELS - (i + 1)));
 	}
 
 	ao2_unlock(multiplexed_thread);
+
+	if (thread != AST_PTHREADT_NULL) {
+		pthread_join(thread, NULL);
+	}
 
 	return;
 }




More information about the asterisk-commits mailing list