[asterisk-dev] Global channel variables
tilghman at mail.jeffandtilghman.com
Fri Nov 23 10:38:47 CST 2007
On Friday 23 November 2007 08:37:17 Atis Lezdins wrote:
> Current implementation is some mixture of "mathematical variables" as
> in xslt, where you can't change variable after it's set, and
> "programming variables" where you can change them if you have access
> to them. As dialplan isn't as flexible as xslt, i really miss is
> ability to set variables of parent channel. This can be done with
> internal db, but it's quite an overhead for dialplan to do that, and
> remember to update them all the time.
> What i propose - to create concept of "global channel variables" that
> would be held in top-channel, and automatically updated from all child
> channels (when changes are made). They could have prefix of three
> underscores, or if those changes won't affect performance in
> noticeable way - they could simply replace two-underscore variables.
The problem with this is the old "pull the rug out from underneath ourselves"
issue. If you allow setting variables from another, you run the risk of
changing the value in the middle of logic, quite possibly changing the
results of some calculation in some unforeseen way (for example logic which
explicitly checks if a value is not zero to avoid a division by zero error,
then divides could find that it still gets a division-by-zero error, because
the value was changed in the middle.)
So the obvious fix for this is to segregate those variables into a separate
space, where both channels can be aware that those values are shared and
could be changed at any time. And that is the solution in your first
paragraph (astdb or another database), which you seem to be opposed to. We
like that solution better, because it avoids obvious race conditions.
More information about the asterisk-dev