aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_chanspy.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-19 18:50:53 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-19 18:50:53 +0000
commitcb9f689b101a55af4f412a178d33edbff75ac53d (patch)
tree4ab3354c4b6a0c426c652c0b82f09b5350adaff4 /apps/app_chanspy.c
parentab705f858d9897f4aa07a1e7bfaed9a21dae7102 (diff)
Add a lock and unlock prior to the destruction of the chanspy_ds
lock to ensure that no other threads still have it locked. While this should not happen under normal circumstances, it appears that if the spyer and spyee hang up at nearly the same time, the following may occur. 1. ast_channel_free is called on the spyee's channel. 2. The chanspy datastore is removed from the spyee's channel in ast_channel_free. 3. In the spyer's thread, the spyer attempts to remove and destroy the datastore from the spyee channel, but the datastore has already been removed in step 2, so the spyer continues in the code. 4. The spyee's thread continues and calls the datastore's destroy callback, chanspy_ds_destroy. This involves locking the chanspy_ds. 5. Now the spyer attempts to destroy the chanspy_ds lock. The problem is that in step 4, the spyee has locked this lock, meaning that the spyer is attempting to destroy a lock which is currently locked by another thread. The backtrace provided in issue #12969 supports the idea that this is possible (and has even occurred). This commit does not close the issue, but should help in preventing one type of crash associated with the use of app_chanspy. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@138886 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 80af5b234..aba4c3a52 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -674,6 +674,8 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
+ ast_mutex_lock(&chanspy_ds.lock);
+ ast_mutex_unlock(&chanspy_ds.lock);
ast_mutex_destroy(&chanspy_ds.lock);
return res;