<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13962">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><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;"><span>diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c</span><br><span>index a5c27bf..09148cc 100644</span><br><span>--- a/apps/app_mixmonitor.c</span><br><span>+++ b/apps/app_mixmonitor.c</span><br><span>@@ -987,6 +987,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 4db32ea..ed16897 100644</span><br><span>--- a/main/audiohook.c</span><br><span>+++ b/main/audiohook.c</span><br><span>@@ -502,6 +502,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/+/13962">change 13962</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/+/13962"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 17 </div>
<div style="display:none"> Gerrit-Change-Id: I8044c06daa06f0f16607788c596f55623be26f58 </div>
<div style="display:none"> Gerrit-Change-Number: 13962 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>