[Home]

Summary:ASTERISK-26627: func_global: Provide better documentation for usage of SHARED
Reporter:Jonathan Harris (lardconcepts)Labels:
Date Opened:2016-11-27 08:20:22.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Functions/func_global
Versions:14.2.0 Frequency of
Occurrence
Related
Issues:
Environment:Linux 4.8.0-27-generic #29-Ubuntu SMP Thu Oct 20 21:03:13 UTC 2016 x86_64 x86_64 x86_64 GNU/LinuxAttachments:( 0) debug_log_123456.txt
Description:For the following code:
{code}
[svtest1]
exten => s,1,Answer()
   same => n,Verbose(1,Answered channel:${CHANNEL})
   same => n,Dial(Local/s@svtest2,,g)
   same => n,Verbose(1,***In channel:${CHANNEL} sharedVar: ${SHARED(sharedVar,Local/s@svtest2)} )
   same => n,Hangup()  
   
[svtest2]
exten => s,1,NoOp()
   same => n,Set(SHARED(sharedVar,Local/s@svtest2)="I have been set in svtest2")
   same => n,Verbose(1,***In channel:${CHANNEL} sharedVar: ${SHARED(sharedVar,Local/s@svtest2)})
   same => n,Answer()
   same => n,Hangup()  
{code}

I get the following output, dialled 4 times from console, 4 times from a normal PJSIP softphone:

Of the 8 attempts. in only 3 instances the variable survives the journey back to the parent channel, and seemingly randomly, too.
Am I using it incorrectly?
{code}
CLI> originate local/s@svtest1 application echo
Answered channel:Local/s@svtest1-00000027;2
***In channel:Local/s@svtest2-00000028;2 sharedVar: "I have been set in svtest2"
***In channel:Local/s@svtest1-00000027;2 sharedVar:
CLI> originate local/s@svtest1 application echo
Answered channel:Local/s@svtest1-00000029;2
***In channel:Local/s@svtest2-0000002a;2 sharedVar: "I have been set in svtest2"
***In channel:Local/s@svtest1-00000029;2 sharedVar:
CLI> originate local/s@svtest1 application echo
Answered channel:Local/s@svtest1-0000002b;2
***In channel:Local/s@svtest2-0000002c;2 sharedVar: "I have been set in svtest2"
***In channel:Local/s@svtest1-0000002b;2 sharedVar: "I have been set in svtest2"
CLI> originate local/s@svtest1 application echo
Answered channel:Local/s@svtest1-0000002d;2
***In channel:Local/s@svtest2-0000002e;2 sharedVar: "I have been set in svtest2"
***In channel:Local/s@svtest1-0000002d;2 sharedVar:
Answered channel:PJSIP/6001-00000007
***In channel:Local/s@svtest2-0000002f;2 sharedVar: "I have been set in svtest2"
***In channel:PJSIP/6001-00000007 sharedVar: "I have been set in svtest2"
Answered channel:PJSIP/6001-00000008
***In channel:Local/s@svtest2-00000030;2 sharedVar: "I have been set in svtest2"
***In channel:PJSIP/6001-00000008 sharedVar:
Answered channel:PJSIP/6001-00000009
***In channel:Local/s@svtest2-00000031;2 sharedVar: "I have been set in svtest2"
***In channel:PJSIP/6001-00000009 sharedVar:
Answered channel:PJSIP/6001-0000000a
***In channel:Local/s@svtest2-00000032;2 sharedVar: "I have been set in svtest2"
***In channel:PJSIP/6001-0000000a sharedVar: "I have been set in svtest2"
{code}
Comments:By: Asterisk Team (asteriskteam) 2016-11-27 08:20:23.553-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Jonathan Harris (lardconcepts) 2016-11-27 08:20:55.481-0600

Debug log

By: Jonathan Harris (lardconcepts) 2016-11-27 11:07:12.778-0600

OK, it turns out that a shared variable has a rather random tendency, depending on channel states as explained here:
http://lists.digium.com/pipermail/asterisk-users/2016-November/290430.html

So, this may not actually be a bug, but the docs could certainly do with more clarification.