diff options
author | Joshua Colp <jcolp@digium.com> | 2017-06-19 16:49:39 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-06-19 16:49:39 -0500 |
commit | 57bbba7d4326215083eb35ff84ff779780ff9c22 (patch) | |
tree | d87caf34890a45e868b1d43f1bbe5e050ddd2275 | |
parent | 3f5bf287a20b7c613d0ff9db0e9c709fd639ccf1 (diff) | |
parent | 854a6de819b8c14b7493fde28460eb4f9fb305e3 (diff) |
Merge "res_stasis: Plug reference leak on stolen channels"
-rw-r--r-- | main/channel.c | 9 | ||||
-rw-r--r-- | res/res_stasis.c | 20 |
2 files changed, 24 insertions, 5 deletions
diff --git a/main/channel.c b/main/channel.c index 1ca485e7a..8b4dc75be 100644 --- a/main/channel.c +++ b/main/channel.c @@ -998,6 +998,9 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char * 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; } @@ -2217,6 +2220,8 @@ static void ast_channel_destructor(void *obj) char device_name[AST_CHANNEL_NAME]; 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); @@ -2579,6 +2584,9 @@ void ast_hangup(struct ast_channel *chan) 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); @@ -2638,7 +2646,6 @@ void ast_hangup(struct ast_channel *chan) 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 9ea0d63fe..899c8f720 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -1069,8 +1069,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; @@ -1111,8 +1121,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"); |