<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13941">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">audiohook: Don't allow audiohooks to attach to hung up channels.<br><br>Given a scenario where MixMonitor was initiated over AMI it<br>was possible for the channel and MixMonitor thread to remain<br>alive past hang up of the channel. This scenario required<br>the AMI initiated MixMonitor to retrieve the channel, a<br>hangup to occur on the channel in another thread, and then<br>for MixMonitor to actually start. If this occurred the<br>MixMonitor thread would remain alive indefinitely and<br>the channel reference would remain.<br><br>This change ensures that audiohooks are never able to<br>be attached to channels that have been hung up. An<br>additional fix has also been done in app_mixmonitor to<br>properly release the channel reference if this occurs.<br><br>ASTERISK-28780<br><br>Change-Id: I8044c06daa06f0f16607788c596f55623be26f58<br>---<br>M apps/app_mixmonitor.c<br>M main/audiohook.c<br>2 files changed, 10 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/13941/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c</span><br><span>index ad3ac99..41d0133 100644</span><br><span>--- a/apps/app_mixmonitor.c</span><br><span>+++ b/apps/app_mixmonitor.c</span><br><span>@@ -992,6 +992,7 @@</span><br><span>    if (startmon(chan, &mixmonitor->audiohook)) {</span><br><span>                 ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",</span><br><span>                   mixmonitor_spy_type, ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+         ast_autochan_destroy(mixmonitor->autochan);</span><br><span>               ast_audiohook_destroy(&mixmonitor->audiohook);</span><br><span>                mixmonitor_free(mixmonitor);</span><br><span>                 return -1;</span><br><span>diff --git a/main/audiohook.c b/main/audiohook.c</span><br><span>index 3feb114..b6ce43a 100644</span><br><span>--- a/main/audiohook.c</span><br><span>+++ b/main/audiohook.c</span><br><span>@@ -499,6 +499,15 @@</span><br><span> {</span><br><span>  ast_channel_lock(chan);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+   /* Don't allow an audiohook to be attached to a channel that is already hung up.</span><br><span style="color: hsl(120, 100%, 40%);">+   * The hang up process is what actually notifies the audiohook that it should</span><br><span style="color: hsl(120, 100%, 40%);">+  * stop.</span><br><span style="color: hsl(120, 100%, 40%);">+       */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                ast_channel_unlock(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+             return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (!ast_channel_audiohooks(chan)) {</span><br><span>                 struct ast_audiohook_list *ahlist;</span><br><span>           /* Whoops... allocate a new structure */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13941">change 13941</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13941"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I8044c06daa06f0f16607788c596f55623be26f58 </div>
<div style="display:none"> Gerrit-Change-Number: 13941 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>