<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/5860">View Change</a></p><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, 10 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/60/5860/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/channel.c b/main/channel.c<br>index 2addfb5..8d170bc 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -1001,6 +1001,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>@@ -2227,6 +2230,8 @@<br> char device_name[AST_CHANNEL_NAME];<br> struct 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>@@ -2672,6 +2677,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>@@ -2731,7 +2739,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>@@ -10745,7 +10752,6 @@<br> <br> ast_channel_unlock(dest);<br> ast_channel_unlock(source);<br>-<br> channel_do_masquerade(dest, source);<br> return 0;<br> }<br>diff --git a/res/res_stasis.c b/res/res_stasis.c<br>index 9d7bc4c..792f81c 100644<br>--- a/res/res_stasis.c<br>+++ b/res/res_stasis.c<br>@@ -1058,7 +1058,7 @@<br> struct stasis_app_control *control;<br> <br> /* find control */<br>- control = ao2_callback(app_controls, 0, masq_match_cb, old_chan);<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>@@ -1072,6 +1072,7 @@<br> remove_masquerade_store(old_chan);<br> <br> ao2_cleanup(control);<br>+<br> }<br> <br> static void channel_replaced_cb(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5860">change 5860</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/5860"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14 </div>
<div style="display:none"> Gerrit-Change-Number: 5860 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>