diff options
author | George Joseph <gjoseph@digium.com> | 2017-06-16 08:31:04 -0600 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2017-06-16 15:06:56 -0500 |
commit | edfdb4dff5d8438bdb1dfb526c57618944ea6bf3 (patch) | |
tree | 551a2deeed85f1a5bfaa127deb41d65062919354 /res/res_stasis.c | |
parent | 0b7a0681a322de2e49de68c735a47037507a2f50 (diff) |
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
Diffstat (limited to 'res/res_stasis.c')
-rw-r--r-- | res/res_stasis.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/res/res_stasis.c b/res/res_stasis.c index 9d7bc4c24..b1cea3ad5 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -1057,8 +1057,18 @@ static void channel_stolen_cb(void *data, struct ast_channel *old_chan, struct a { 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 @@ static void channel_replaced_cb(void *data, struct ast_channel *old_chan, struct 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"); |