Question about script variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about script variables

Denys Pozniak
Hello!

I am newbie in OpenSIPS and probably my question is stupid, but I could not sleep without correct answer :) 
In the book Building Telephony Systems with OpenSIPS Second Edition I found next part (p. 97):

The script variables
As the name indicates, these variables are strictly bound to the scripting routes. The
variables are visible only in the routing blocks and they have no persistency—when
the route (with all its subroutes) ends, the variables are discarded.

Is it correct explanation?According to this, variable lives on SIP message level when script are executing, but I think something is not correct as variable lives on proccess level.

Please help me to sort out this!

BR
Denys
 

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Question about script variables

Liviu Chircu

Hi Denys,

The book is doing the correct thing - educating the script writer that he must not rely on any $var() holders once an instance of script execution ends for a given message.

You, on the other hand, have the additional knowledge of an underlying optimization: the $var() values are not reset (actually, they are rarely touched at all beyond the script manipulations). The fact that you occasionally find the value that you left in the previous message is just a coincidence, and you cannot reliably use their initial values. Since this is just a "nice to know" developer quirk, I think it would cause confusion if the authors were to include it in the book.

If you talk C, you can think of $vars as "uninitialized stack variables".

Regards,

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 23.11.2017 14:13, Denys Pozniak wrote:
Hello!

I am newbie in OpenSIPS and probably my question is stupid, but I could not sleep without correct answer :) 
In the book Building Telephony Systems with OpenSIPS Second Edition I found next part (p. 97):

The script variables
As the name indicates, these variables are strictly bound to the scripting routes. The
variables are visible only in the routing blocks and they have no persistency—when
the route (with all its subroutes) ends, the variables are discarded.

Is it correct explanation?According to this, variable lives on SIP message level when script are executing, but I think something is not correct as variable lives on proccess level.

Please help me to sort out this!

BR
Denys
 


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Question about script variables

Denys Pozniak
Thank you for the explanation!


On 23 November 2017 at 14:34, Liviu Chircu <[hidden email]> wrote:

Hi Denys,

The book is doing the correct thing - educating the script writer that he must not rely on any $var() holders once an instance of script execution ends for a given message.

You, on the other hand, have the additional knowledge of an underlying optimization: the $var() values are not reset (actually, they are rarely touched at all beyond the script manipulations). The fact that you occasionally find the value that you left in the previous message is just a coincidence, and you cannot reliably use their initial values. Since this is just a "nice to know" developer quirk, I think it would cause confusion if the authors were to include it in the book.

If you talk C, you can think of $vars as "uninitialized stack variables".

Regards,

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 23.11.2017 14:13, Denys Pozniak wrote:
Hello!

I am newbie in OpenSIPS and probably my question is stupid, but I could not sleep without correct answer :) 
In the book Building Telephony Systems with OpenSIPS Second Edition I found next part (p. 97):

The script variables
As the name indicates, these variables are strictly bound to the scripting routes. The
variables are visible only in the routing blocks and they have no persistency—when
the route (with all its subroutes) ends, the variables are discarded.

Is it correct explanation?According to this, variable lives on SIP message level when script are executing, but I think something is not correct as variable lives on proccess level.

Please help me to sort out this!

BR
Denys
 


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--

BR
Denys Pozniak

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users