mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
chan_sip.c: Fix channel staging assertion failure.
The failing assertion ensures that the final snapshot gets generated so CDR records can get finalized. The only place where a channel staging snapshot flag could be left set is in chan_sip.c:handle_request_bye(). The function could return before clearing the flag because the channel could dissappear while the function had to have the channel unlocked. * Fixed handle_request_bye() channel snapshot staging coverage area to not have a return in the middle of it and be unable to clear the staging flag. * Pushed the channel snapshot staging coverage area into ast_rtp_instance_set_stats_vars() to ensure that the staging is not interrutped. * Made callers of ast_rtp_instance_set_stats_vars() not call it with any channels or channel driver private locks held to eliminate the deadlock potential. The callers must hold references to the passed in channel and rtp objects. * Eliminated sip_hangup() trying to get the bridge peer. It is futile at this point because the channel could never be in a bridge. Review: https://reviewboard.asterisk.org/r/3431/ ........ Merged revisions 412385 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412386 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1305,36 +1305,64 @@ char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_r
|
||||
|
||||
void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance)
|
||||
{
|
||||
char quality_buf[AST_MAX_USER_FIELD], *quality;
|
||||
RAII_VAR(struct ast_channel *, bridge, ast_channel_bridge_peer(chan), ast_channel_cleanup);
|
||||
char quality_buf[AST_MAX_USER_FIELD];
|
||||
char *quality;
|
||||
struct ast_channel *bridge = ast_channel_bridge_peer(chan);
|
||||
|
||||
if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
|
||||
ast_channel_lock(chan);
|
||||
ast_channel_stage_snapshot(chan);
|
||||
ast_channel_unlock(chan);
|
||||
if (bridge) {
|
||||
ast_channel_lock(bridge);
|
||||
ast_channel_stage_snapshot(bridge);
|
||||
ast_channel_unlock(bridge);
|
||||
}
|
||||
|
||||
quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY,
|
||||
quality_buf, sizeof(quality_buf));
|
||||
if (quality) {
|
||||
pbx_builtin_setvar_helper(chan, "RTPAUDIOQOS", quality);
|
||||
if (bridge) {
|
||||
pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSBRIDGED", quality);
|
||||
}
|
||||
}
|
||||
|
||||
if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf)))) {
|
||||
quality = ast_rtp_instance_get_quality(instance,
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf));
|
||||
if (quality) {
|
||||
pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSJITTER", quality);
|
||||
if (bridge) {
|
||||
pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSJITTERBRIDGED", quality);
|
||||
}
|
||||
}
|
||||
|
||||
if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf)))) {
|
||||
quality = ast_rtp_instance_get_quality(instance,
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf));
|
||||
if (quality) {
|
||||
pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSLOSS", quality);
|
||||
if (bridge) {
|
||||
pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSLOSSBRIDGED", quality);
|
||||
}
|
||||
}
|
||||
|
||||
if ((quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf)))) {
|
||||
quality = ast_rtp_instance_get_quality(instance,
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf));
|
||||
if (quality) {
|
||||
pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSRTT", quality);
|
||||
if (bridge) {
|
||||
pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSRTTBRIDGED", quality);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format)
|
||||
|
Reference in New Issue
Block a user