[svn-commits] file: branch file/bridging r107717 - /team/file/bridging/main/bridging.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 11 15:53:11 CDT 2008


Author: file
Date: Tue Mar 11 15:53:11 2008
New Revision: 107717

URL: http://svn.digium.com/view/asterisk?view=rev&rev=107717
Log:
Only try to get control of the bridge thread if one is running.

Modified:
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=107717&r1=107716&r2=107717
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Tue Mar 11 15:53:11 2008
@@ -519,20 +519,24 @@
 	/* 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);
-	pthread_kill(thread, SIGURG);
-	
-	/* Once we let go of the lock the bridge thread should quit and control should be given to us */
-	ast_mutex_unlock(&bridge->lock);
-
-	/* Of course we have to wait for the thread to exit, that can take some time */
-	ast_debug(1, "Waiting for current bridge thread on %p to exit and control to return to us\n", bridge);
-	pthread_join(thread, NULL);
-	
-	/* Now that it is back to us we have to reacquire the lock so we can muck with things :D */
-	ast_mutex_lock(&bridge->lock);
+	/* Only try to join the bridge thread if one is running */
+	if (bridge->thread != AST_PTHREADT_NULL) {
+		/* 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);
+		pthread_kill(thread, SIGURG);
+		
+		/* Once we let go of the lock the bridge thread should quit and control should be given to us */
+		ast_mutex_unlock(&bridge->lock);
+		
+		/* Of course we have to wait for the thread to exit, that can take some time */
+		ast_debug(1, "Waiting for current bridge thread on %p to exit and control to return to us\n", bridge);
+		pthread_join(thread, NULL);
+		
+		/* Now that it is back to us we have to reacquire the lock so we can muck with things :D */
+		ast_mutex_lock(&bridge->lock);
+	}
+
 	ast_debug(1, "Control of bridge %p now belongs to the smart bridge operation\n", bridge);
 
 	/* Since we have a temporary bridge structure up above we can make the current one clean */




More information about the svn-commits mailing list