[asterisk-commits] res stasis: Plug reference leak on stolen channels (asterisk[13])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 19 11:38:03 CDT 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5860 )
Change subject: res_stasis: Plug reference leak on stolen channels
......................................................................
res_stasis: Plug reference leak on stolen channels
When a stasis channel is stolen by another app, the control
structure is unreffed but never unlinked from the app_controls
container. This causes the channel reference to leak.
Added OBJ_UNLINK to the callback in channel_stolen_cb.
Also added some additional channel lifecycle debug messages to
channel.c.
ASTERISK-27059 #close
Repoorted-by: George Joseph
Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14
---
M main/channel.c
M res/res_stasis.c
2 files changed, 24 insertions(+), 5 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/channel.c b/main/channel.c
index 2addfb5..c5060b7 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1001,6 +1001,9 @@
* the world know of its existance
*/
ast_channel_stage_snapshot_done(tmp);
+
+ ast_debug(1, "Channel %p '%s' allocated\n", tmp, ast_channel_name(tmp));
+
return tmp;
}
@@ -2227,6 +2230,8 @@
char device_name[AST_CHANNEL_NAME];
struct ast_callid *callid;
+ ast_debug(1, "Channel %p '%s' destroying\n", chan, ast_channel_name(chan));
+
/* Stop monitoring */
if (ast_channel_monitor(chan)) {
ast_channel_monitor(chan)->stop(chan, 0);
@@ -2672,6 +2677,9 @@
return;
}
+ ast_debug(1, "Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
+ ao2_ref(chan, 0));
+
ast_autoservice_stop(chan);
ast_channel_lock(chan);
@@ -2731,7 +2739,6 @@
ast_assert(ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING) == 0);
}
- ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan));
if (ast_channel_tech(chan)->hangup) {
ast_channel_tech(chan)->hangup(chan);
}
diff --git a/res/res_stasis.c b/res/res_stasis.c
index 9d7bc4c..b1cea3a 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -1057,8 +1057,18 @@
{
struct stasis_app_control *control;
- /* find control */
- control = ao2_callback(app_controls, 0, masq_match_cb, old_chan);
+ /*
+ * At this point, old_chan is the channel pointer that is in Stasis() and
+ * has the unknown channel's name in it while new_chan is the channel pointer
+ * that is not in Stasis(), but has the guts of the channel that Stasis() knows
+ * about.
+ *
+ * Find and unlink control since the channel has a new name/uniqueid
+ * and its hash has changed. Since the channel is leaving stasis don't
+ * bother putting it back into the container. Nobody is going to
+ * remove it from the container later.
+ */
+ control = ao2_callback(app_controls, OBJ_UNLINK, masq_match_cb, old_chan);
if (!control) {
ast_log(LOG_ERROR, "Could not find control for masqueraded channel\n");
return;
@@ -1099,8 +1109,10 @@
return;
}
- /* find, unlink, and relink control since the channel has a new name and
- * its hash has likely changed */
+ /*
+ * Find, unlink, and relink control since the channel has a new
+ * name/uniqueid and its hash has changed.
+ */
control = ao2_callback(app_controls, OBJ_UNLINK, masq_match_cb, new_chan);
if (!control) {
ast_log(LOG_ERROR, "Could not find control for masquerading channel\n");
--
To view, visit https://gerrit.asterisk.org/5860
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14
Gerrit-Change-Number: 5860
Gerrit-PatchSet: 4
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170619/91204254/attachment-0001.html>
More information about the asterisk-commits
mailing list