From cc97c2a81f209b588d14095aa3671ae511d34fff Mon Sep 17 00:00:00 2001 From: russell Date: Wed, 11 Mar 2009 22:15:40 +0000 Subject: Merged revisions 181428 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r181428 | russell | 2009-03-11 17:14:55 -0500 (Wed, 11 Mar 2009) | 2 lines Make handling of the BRIDGEPVTCALLID variable thread-safe. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@181429 f38db490-d61c-443f-a65b-d21fe96a405b --- main/channel.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'main') diff --git a/main/channel.c b/main/channel.c index 2c9724ad9..0b4d154bf 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4527,26 +4527,40 @@ static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, st S_OR(c1->cid.cid_num, "")); } -static void update_bridgepeer(struct ast_channel *c0, struct ast_channel *c1) +static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1) { const char *c0_name; const char *c1_name; + const char *c0_pvtid = NULL; + const char *c1_pvtid = NULL; ast_channel_lock(c1); c1_name = ast_strdupa(c1->name); + if (c1->tech->get_pvt_uniqueid) { + c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1)); + } ast_channel_unlock(c1); ast_channel_lock(c0); if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) { pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1_name); } + if (c1_pvtid) { + pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid); + } c0_name = ast_strdupa(c0->name); + if (c0->tech->get_pvt_uniqueid) { + c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0)); + } ast_channel_unlock(c0); ast_channel_lock(c1); if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) { pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0_name); } + if (c0_pvtid) { + pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0_pvtid); + } ast_channel_unlock(c1); } @@ -4702,12 +4716,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha break; } - update_bridgepeer(c0, c1); - - if (c0->tech->get_pvt_uniqueid) - pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0->tech->get_pvt_uniqueid(c0)); - if (c1->tech->get_pvt_uniqueid) - pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1->tech->get_pvt_uniqueid(c1)); + update_bridge_vars(c0, c1); if (c0->tech->bridge && (c0->tech->bridge == c1->tech->bridge) && @@ -4767,7 +4776,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha o1nativeformats = c1->nativeformats; } - update_bridgepeer(c0, c1); + update_bridge_vars(c0, c1); res = ast_generic_bridge(c0, c1, config, fo, rc, config->nexteventts); if (res != AST_BRIDGE_RETRY) { -- cgit v1.2.3