[asterisk-bugs] [Asterisk 0011943]: Feature to write variables to existing channels other than your own (func chanvar)

noreply at bugs.digium.com noreply at bugs.digium.com
Thu Feb 7 08:07:07 CST 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=11943 
====================================================================== 
Reported By:                ramonpeek
Assigned To:                russell
====================================================================== 
Project:                    Asterisk
Issue ID:                   11943
Category:                   Functions/func_logic
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     assigned
Asterisk Version:           SVN 
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             02-06-2008 15:08 CST
Last Modified:              02-07-2008 08:07 CST
====================================================================== 
Summary:                    Feature to write variables to existing channels
other than your own (func chanvar)
Description: 
Many, many times I ran into a dialplan issue where I wanted to set a
variable in the called channel whilst the dialplan was running in the
calling channel.
To my frustration an application like ImportVar() existed but something
like ExportVar() did not.

After bumping into the issue a bit too often I deciced to write it myself
:-)
It probably took me less time writing the patch than it took finding out
ways to realize this feature with the current set of applications &
functions :-(

Anyway...
I started out writing the patch for 1.4.17 and called it 'ExportVar'.
But after finding out it was deprecated in the svn-trunk and talking to
Digium (Qwell) about it,
I decided to create a new logical function in func_logic called
'CHANVAR'.
This feature includes read & write making function 'ImportVar' & 'IMPORT'
both obsolete.
Since function 'IMPORT' is only in teh svn-trunk perhaps it should be
removed or deprecated if this patch gets submitted. 

This is how the new feature works;

To read a variable from another channel;
- Set(CHANVAR(channel,variable)=value)

To write a variable to another channel;
- Set(varname=${CHANVAR(channel,variable)})


PS:
For everyone that wants to add this feature (themselves) to Asterisk
1.4.17 a path to backport to 1.4.17 is also uploaded.
====================================================================== 

---------------------------------------------------------------------- 
 Corydon76 - 02-07-08 08:07  
---------------------------------------------------------------------- 
The last quoted paragraph denotes why this is a bad idea:

> There's no need.  A database does this just fine already, in a
> completely predictable way.  Setting another channel's variables
> asynchronously is not a smart idea.  For example, if one channel
> is using ${i} to iterate through a loop and you asynchronously change
> the value of ${i} halfway through the loop, the dialplan is going to do
> something unpredictable and completely unreproduceable.

The ONLY way to ensure that a channel variable does not interfere with
logic is to allow a channel the privilege of importing a variable from
another channel.  In other words, it's fine for you to copy a tattoo I
have, but it's incredibly bad for me to show up in the middle of the night
and tattoo your back (without asking first). 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
02-07-08 08:07  Corydon76      Note Added: 0081843                          
======================================================================




More information about the asterisk-bugs mailing list