Summary: | ASTERISK-23133: Documentation fix - MASTER_CHANNEL Unexpected Behaviour | ||
Reporter: | Shane Mitchell (smirker) | Labels: | |
Date Opened: | 2014-01-10 19:56:14.000-0600 | Date Closed: | 2017-12-29 13:32:11.000-0600 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Functions/General |
Versions: | 1.8.25.0 11.7.0 13.18.4 | Frequency of Occurrence | Constant |
Related Issues: | |||
Environment: | n/a | Attachments: | |
Description: | MASTER_CHANNEL() should behave, as per documentation: Allows access to the channel which created the current channel, if any. If the channel is already a master channel, then accesses local channel variables.
MASTER_CHANNEL() actually accesses the local variables of the initial/first channel and not the parent channel. Hence, either the behaviour of MASTER_CHANNEL is incorrect or the documentation is incorrect. This behaviour is experienced every way you can spawn a channel, including but not limited to local channels, the U option in Dial, etc. {noformat} [channel1] exten => s,1,Set(CHANLEVEL=1) same => n,NoOp(${CHANLEVEL}) ; OUTPUT IS: 1 same => n,NoOp(${MASTER_CHANNEL(CHANLEVEL)}) ; OUTPUT IS: 1 (OK) same => n,Dial(Local/s@channel2) [channel2] exten => s,1,Set(CHANLEVEL=2) same => n,NoOp(${CHANLEVEL}) ; OUTPUT IS: 2 same => n,NoOp(${MASTER_CHANNEL(CHANLEVEL)}) ; OUTPUT IS: 1 (OK) same => n,Dial(Local/s@channel3) [channel3] exten => s,1,Set(CHANLEVEL=3) same => n,NoOp(${CHANLEVEL}) ; OUTPUT IS: 3 same => n,NoOp(${MASTER_CHANNEL(CHANLEVEL)}) ; OUTPUT IS: 1 (UNEXPECTED) {noformat} I would posit from the naming of the MASTER_CHANNEL function that its behaviour is correct and the documentation is incorrect. However, it is important to be able to access the 'channel which created the current channel' as well - and this functionality is missing. Deviating from the Asterisk issue guidelines slightly, in addition to correcting the documentation, it would be of huge value to have a function similarly named to PARENT_CHANNEL() which behaves as per the documentation pasted above (accessing the channel which created the current channel / the parent channel). | ||
Comments: | By: Marcus Hunger (fnordian) 2015-07-21 10:58:36.193-0500 Any updates on this? I need the functionality as documented. By: Joshua C. Colp (jcolp) 2015-07-21 11:03:28.847-0500 Any updates will be posted on this issue. As there are none there have been no updates. By: dovid (dovid) 2017-12-27 04:10:25.293-0600 @ Shane Mitchell I had this exact issue and from the docs understood it the way you did. I agree such functionality would help. For now what you can is pass the channel as an arg and then use the SHARED function. By: Friendly Automation (friendly-automation) 2017-12-29 13:32:13.176-0600 Change 7750 merged by Jenkins2: func_channel.c: Update MASTER_CHANNEL documentation [https://gerrit.asterisk.org/7750|https://gerrit.asterisk.org/7750] By: Friendly Automation (friendly-automation) 2017-12-29 13:40:01.363-0600 Change 7751 merged by Jenkins2: func_channel.c: Update MASTER_CHANNEL documentation [https://gerrit.asterisk.org/7751|https://gerrit.asterisk.org/7751] By: Friendly Automation (friendly-automation) 2017-12-29 13:41:38.687-0600 Change 7752 merged by Jenkins2: func_channel.c: Update MASTER_CHANNEL documentation [https://gerrit.asterisk.org/7752|https://gerrit.asterisk.org/7752] |