[asterisk-commits] file: trunk r73359 - in /trunk: ./ apps/app_chanspy.c main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 5 09:22:59 CDT 2007


Author: file
Date: Thu Jul  5 09:22:58 2007
New Revision: 73359

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73359
Log:
Merged revisions 73355 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r73355 | file | 2007-07-05 11:21:44 -0300 (Thu, 05 Jul 2007) | 10 lines

Merged revisions 73349 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r73349 | file | 2007-07-05 11:19:14 -0300 (Thu, 05 Jul 2007) | 2 lines

Tweak spy locking. (issue #9951 reported by welles)

........

................

Modified:
    trunk/   (props changed)
    trunk/apps/app_chanspy.c
    trunk/main/channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=73359&r1=73358&r2=73359
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Thu Jul  5 09:22:58 2007
@@ -425,9 +425,10 @@
 	else
 		ast_deactivate_generator(chan);
 
+	csth.spy.status = CHANSPY_DONE;
+
 	/* If a channel still exists on our spy structure then we need to remove ourselves */
 	if (csth.spy.chan) {
-		csth.spy.status = CHANSPY_DONE;
 		ast_channel_lock(csth.spy.chan);
 		ast_channel_spy_remove(csth.spy.chan, &csth.spy);
 		ast_channel_unlock(csth.spy.chan);

Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=73359&r1=73358&r2=73359
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Thu Jul  5 09:22:58 2007
@@ -1347,23 +1347,21 @@
 /* Detach a spy from it's channel */
 static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
 {
-	ast_mutex_lock(&spy->lock);
-
 	/* We only need to poke them if they aren't already done */
 	if (spy->status != CHANSPY_DONE) {
+		ast_mutex_lock(&spy->lock);
 		/* Indicate to the spy to stop */
 		spy->status = CHANSPY_STOP;
 		spy->chan = NULL;
 		/* Poke the spy if needed */
 		if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
 			ast_cond_signal(&spy->trigger);
+		ast_mutex_unlock(&spy->lock);
 	}
 
 	/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
 	ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name);
 
-	ast_mutex_unlock(&spy->lock);
-
 	return;
 }
 
@@ -1375,13 +1373,10 @@
 		return;
 
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
-		ast_mutex_lock(&spy->lock);
 		if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
-			ast_mutex_unlock(&spy->lock);
 			AST_LIST_REMOVE_CURRENT(&chan->spies->list, list);
 			spy_detach(spy, chan);
-		} else
-			ast_mutex_unlock(&spy->lock);
+		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END
 	spy_cleanup(chan);
@@ -1492,6 +1487,9 @@
 	AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
 		struct ast_channel_spy_queue *queue;
 		struct ast_frame *duped_fr;
+
+		if (spy->status != CHANSPY_RUNNING)
+			continue;
 
 		ast_mutex_lock(&spy->lock);
 




More information about the asterisk-commits mailing list