summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-02-14 07:14:50 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-02-14 07:14:51 -0600
commit72845bd4b56bc18a0eefe2c3cb9c4a2f6117f460 (patch)
treedfc50528dec7201978638c4df1cfa4608551277b /main
parentc68e52d2130384c381a5c08423c2bbdf9a93b6b9 (diff)
parent16fdb11bc3bb23a2fd645a24a7ba56d9708960ff (diff)
Merge "core: Cleanup some channel snapshot staging anomalies."
Diffstat (limited to 'main')
-rw-r--r--main/channel.c21
-rw-r--r--main/rtp_engine.c14
2 files changed, 18 insertions, 17 deletions
diff --git a/main/channel.c b/main/channel.c
index 234919336..992c94086 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -823,7 +823,12 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_stage_snapshot(tmp);
if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- /* format capabilities structure allocation failure */
+ /*
+ * Aborting the channel creation. We do not need to complete staging
+ * the channel snapshot because the channel has not been finalized or
+ * linked into the channels container yet. Nobody else knows about
+ * this channel nor will anybody ever know about it.
+ */
return ast_channel_unref(tmp);
}
ast_format_cap_append(nativeformats, ast_format_none, 0);
@@ -849,6 +854,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
if (!(schedctx = ast_sched_context_create())) {
ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
+ /* See earlier channel creation abort comment above. */
return ast_channel_unref(tmp);
}
ast_channel_sched_set(tmp, schedctx);
@@ -863,6 +869,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_caller(tmp)->id.name.valid = 1;
ast_channel_caller(tmp)->id.name.str = ast_strdup(cid_name);
if (!ast_channel_caller(tmp)->id.name.str) {
+ /* See earlier channel creation abort comment above. */
return ast_channel_unref(tmp);
}
}
@@ -870,6 +877,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_caller(tmp)->id.number.valid = 1;
ast_channel_caller(tmp)->id.number.str = ast_strdup(cid_num);
if (!ast_channel_caller(tmp)->id.number.str) {
+ /* See earlier channel creation abort comment above. */
return ast_channel_unref(tmp);
}
}
@@ -883,6 +891,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
}
if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
+ /* See earlier channel creation abort comment above. */
return ast_channel_unref(tmp);
}
@@ -974,20 +983,14 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
if (assignedids && (does_id_conflict(assignedids->uniqueid) || does_id_conflict(assignedids->uniqueid2))) {
ast_channel_internal_errno_set(AST_CHANNEL_ERROR_ID_EXISTS);
ao2_unlock(channels);
- /* This is a bit unorthodox, but we can't just call ast_channel_stage_snapshot_done()
- * because that will result in attempting to publish the channel snapshot. That causes
- * badness in some places, such as CDRs. So we need to manually clear the flag on the
- * channel that says that a snapshot is being cleared.
- */
- ast_clear_flag(ast_channel_flags(tmp), AST_FLAG_SNAPSHOT_STAGE);
ast_channel_unlock(tmp);
+ /* See earlier channel creation abort comment above. */
return ast_channel_unref(tmp);
}
+ /* Finalize and link into the channels container. */
ast_channel_internal_finalize(tmp);
-
ast_atomic_fetchadd_int(&chancount, +1);
-
ao2_link_flags(channels, tmp, OBJ_NOLOCK);
ao2_unlock(channels);
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 3ef2d876b..a46546318 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -1899,16 +1899,16 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in
{
char quality_buf[AST_MAX_USER_FIELD];
char *quality;
- struct ast_channel *bridge = ast_channel_bridge_peer(chan);
+ struct ast_channel *bridge;
- ast_channel_lock(chan);
- ast_channel_stage_snapshot(chan);
- ast_channel_unlock(chan);
+ bridge = ast_channel_bridge_peer(chan);
if (bridge) {
- ast_channel_lock(bridge);
+ ast_channel_lock_both(chan, bridge);
ast_channel_stage_snapshot(bridge);
- ast_channel_unlock(bridge);
+ } else {
+ ast_channel_lock(chan);
}
+ ast_channel_stage_snapshot(chan);
quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY,
quality_buf, sizeof(quality_buf));
@@ -1946,11 +1946,9 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in
}
}
- ast_channel_lock(chan);
ast_channel_stage_snapshot_done(chan);
ast_channel_unlock(chan);
if (bridge) {
- ast_channel_lock(bridge);
ast_channel_stage_snapshot_done(bridge);
ast_channel_unlock(bridge);
ast_channel_unref(bridge);