<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/5862">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
Kevin Harwell: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_stasis: Plug reference leak on stolen channels<br><br>When a stasis channel is stolen by another app, the control<br>structure is unreffed but never unlinked from the app_controls<br>container. This causes the channel reference to leak.<br><br>Added OBJ_UNLINK to the callback in channel_stolen_cb.<br><br>Also added some additional channel lifecycle debug messages to<br>channel.c.<br><br>ASTERISK-27059 #close<br>Repoorted-by: George Joseph<br><br>Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14<br>---<br>M main/channel.c<br>M res/res_stasis.c<br>2 files changed, 24 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/channel.c b/main/channel.c<br>index 1ca485e..8b4dc75 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -998,6 +998,9 @@<br> * the world know of its existance<br> */<br> ast_channel_stage_snapshot_done(tmp);<br>+<br>+ ast_debug(1, "Channel %p '%s' allocated\n", tmp, ast_channel_name(tmp));<br>+<br> return tmp;<br> }<br> <br>@@ -2217,6 +2220,8 @@<br> char device_name[AST_CHANNEL_NAME];<br> ast_callid callid;<br> <br>+ ast_debug(1, "Channel %p '%s' destroying\n", chan, ast_channel_name(chan));<br>+<br> /* Stop monitoring */<br> if (ast_channel_monitor(chan)) {<br> ast_channel_monitor(chan)->stop(chan, 0);<br>@@ -2579,6 +2584,9 @@<br> return;<br> }<br> <br>+ ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),<br>+ ao2_ref(chan, 0));<br>+<br> ast_autoservice_stop(chan);<br> <br> ast_channel_lock(chan);<br>@@ -2638,7 +2646,6 @@<br> ast_assert(ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING) == 0);<br> }<br> <br>- ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan));<br> if (ast_channel_tech(chan)->hangup) {<br> ast_channel_tech(chan)->hangup(chan);<br> }<br>diff --git a/res/res_stasis.c b/res/res_stasis.c<br>index 9ea0d63..899c8f7 100644<br>--- a/res/res_stasis.c<br>+++ b/res/res_stasis.c<br>@@ -1069,8 +1069,18 @@<br> {<br> struct stasis_app_control *control;<br> <br>- /* find control */<br>- control = ao2_callback(app_controls, 0, masq_match_cb, old_chan);<br>+ /*<br>+ * At this point, old_chan is the channel pointer that is in Stasis() and<br>+ * has the unknown channel's name in it while new_chan is the channel pointer<br>+ * that is not in Stasis(), but has the guts of the channel that Stasis() knows<br>+ * about.<br>+ *<br>+ * Find and unlink control since the channel has a new name/uniqueid<br>+ * and its hash has changed. Since the channel is leaving stasis don't<br>+ * bother putting it back into the container. Nobody is going to<br>+ * remove it from the container later.<br>+ */<br>+ control = ao2_callback(app_controls, OBJ_UNLINK, masq_match_cb, old_chan);<br> if (!control) {<br> ast_log(LOG_ERROR, "Could not find control for masqueraded channel\n");<br> return;<br>@@ -1111,8 +1121,10 @@<br> return;<br> }<br> <br>- /* find, unlink, and relink control since the channel has a new name and<br>- * its hash has likely changed */<br>+ /*<br>+ * Find, unlink, and relink control since the channel has a new<br>+ * name/uniqueid and its hash has changed.<br>+ */<br> control = ao2_callback(app_controls, OBJ_UNLINK, masq_match_cb, new_chan);<br> if (!control) {<br> ast_log(LOG_ERROR, "Could not find control for masquerading channel\n");<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5862">change 5862</a>. To unsubscribe, 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/5862"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14 </div>
<div style="display:none"> Gerrit-Change-Number: 5862 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>