[asterisk-commits] file: branch file/bridging r107347 - in /team/file/bridging: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 10 21:01:44 CDT 2008
Author: file
Date: Mon Mar 10 21:01:42 2008
New Revision: 107347
URL: http://svn.digium.com/view/asterisk?view=rev&rev=107347
Log:
Wait until the bridge is done going through the smart bridge operation before joining it.
Modified:
team/file/bridging/include/asterisk/bridging.h
team/file/bridging/main/bridging.c
Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=107347&r1=107346&r2=107347
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Mon Mar 10 21:01:42 2008
@@ -135,6 +135,7 @@
ast_mutex_t lock; /*! Lock to protect the bridge */
int num; /*! Number of channels involved in the bridge */
unsigned int rebuild:1; /*! Something outside wants us to rebuild the bridge data */
+ unsigned int smart:1; /*! Bridge is undergoing smart bridge operation */
struct ast_flags feature_flags; /*! Feature flags */
struct ast_bridge_technology *technology; /*! Technology in use on the bridge */
void *bridge_pvt; /*! Private information unique to the bridge technology (not always needed) */
Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=107347&r1=107346&r2=107347
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Mon Mar 10 21:01:42 2008
@@ -516,6 +516,9 @@
ast_debug(1, "Performing smart bridge operation on bridge %p, moving from bridge technology %s to %s\n", bridge, old_technology->name, new_technology->name);
+ /* Mark this bridge as undergoing a smart bridge operation */
+ bridge->smart = 1;
+
/* We start off by getting the thread servicing the current technology to stop and give control to us */
bridge->thread = AST_PTHREADT_STOP;
ast_cond_signal(&bridge->cond);
@@ -578,6 +581,7 @@
if (!bridge_channel && (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_THREAD)) {
if ((bridge->thread == AST_PTHREADT_NULL) && (ast_pthread_create(&bridge->thread, NULL, bridge_thread, bridge))) {
ast_debug(1, "Failed to create bridge thread for %p\n", bridge);
+ bridge->smart = 0;
return -1;
} else {
ast_debug(1, "Poked thread servicing bridge %p\n", bridge);
@@ -585,6 +589,8 @@
pthread_kill(bridge->thread, SIGURG);
}
}
+
+ bridge->smart = 0;
return 0;
}
@@ -883,6 +889,10 @@
bridge_channel.thread = pthread_self();
ast_cond_init(&bridge_channel.cond, NULL);
+ /* If this bridge is undergoing the smart bridge operation wait until it is finished before joining */
+ while (bridge->smart)
+ usleep(1);
+
ast_mutex_lock(&bridge->lock);
/* Add channel to the bridge now, but suspended */
@@ -1006,6 +1016,10 @@
/* Setup synchronization for our thread */
ast_cond_init(&bridge_channel->cond, NULL);
+ /* If this bridge is undergoing the smart bridge operation wait until it is finished before joining */
+ while (bridge->smart)
+ usleep(1);
+
/* Lock the bridge as we are potentially going to muck with it now */
ast_mutex_lock(&bridge->lock);
More information about the asterisk-commits
mailing list