[Home]

Summary:ASTERISK-13388: Variable prefixed with '__' not inherited when call originated via AMI
Reporter:Chris Maciejewski (chris-mac)Labels:
Date Opened:2009-01-17 09:41:02.000-0600Date Closed:2011-06-07 14:02:42
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/Channels
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Despite variable is prefixed with '__' it is no inherited by child channel, when call is originated via AMI. How to reproduce:

extensions.conf
----------%<-------------------
[test1]
exten => _X.,1,NoOp(**** TEST 1 ****)
exten => _X.,n,Set(__X_GLOBAL_VAR=TEST)
exten => _X.,n,Dial(SIP/10000@OpenSER,30)

[test2]
exten => _X.,1,NoOp(**** TEST 2 **** X_GLOBAL_VAR: ${X_GLOBAL_VAR})
exten => _X.,n,Hangup()
----------%<-------------------

AMI:
----------%<-------------------
Action: Originate
Channel: LOCAL/111@test1/n
Context: test2
Exten: 222
Priority: 1
Callerid: Operator
Timeout: 30000
Account: 1
----------%<-------------------

Console output:
----------%<-------------------
 == Manager 'admin' logged on from 127.0.0.1
   -- Executing [111@test1:1] NoOp("Local/111@test1-1dbc;2", "**** TEST 1 ****") in new stack
   -- Executing [111@test1:2] Set("Local/111@test1-1dbc;2", "__X_GLOBAL_VAR=TEST") in new stack
   -- Executing [111@test1:3] Dial("Local/111@test1-1dbc;2", "SIP/10000@OpenSER,30") in new stack
 == Using SIP RTP CoS mark 5
   -- Called 10000@OpenSER
   -- SIP/OpenSER-08205468 is ringing
   -- SIP/OpenSER-08205468 answered Local/111@test1-1dbc;2
      > Channel Local/111@test1-1dbc;1 was answered.
   -- Executing [222@test2:1] NoOp("Local/111@test1-1dbc;1", "**** TEST 2 **** X_GLOBAL_VAR: ") in new stack
   -- Executing [222@test2:2] Hangup("Local/111@test1-1dbc;1", "") in new stack
 == Spawn extension (test2, 222, 2) exited non-zero on 'Local/111@test1-1dbc;1'
 == Spawn extension (test1, 111, 3) exited non-zero on 'Local/111@test1-1dbc;2'
 == Manager 'admin' logged off from 127.0.0.1
----------%<-------------------

NOTE: ${X_GLOBAL_VAR} is not inherited in [test2] context!
Comments:By: Tilghman Lesher (tilghman) 2009-01-17 13:31:25.000-0600

It's actually a consequence of the Local channel type.  The channel variables ARE actually inherited, but they are inherited BEFORE the context runs.  This is because the two parts of the Local channel are created at the same time, so only the variables which you set in the callfile are able to be inherited.  If you really want this, I would suggest that you either use the SHARE() dialplan function to copy variables between the two halves of the Local channel or you use the IMPORT() function in the second context to pull in variables from the first.

For example:
Set(chan1=${CUT(CHANNEL,\;,1)}\;2)
Set(__X_GLOBAL_VAR=${IMPORT(${chan1},X_GLOBAL_VAR)})

By: Chris Maciejewski (chris-mac) 2009-01-20 11:49:09.000-0600

Croydon76: Thank you very much for info.

Indeed setting variables (prefixed with '__') in callfile or via AMI - 'Originate' command make it inheritable by child channels.

Can we please close this bug.

Best regards,
Chris