Hello I have faced when case when private var defined as $var(json_request) is share between different SIP messages. In my case first time this var is used from registration processing route. Then var with same name is used PUBLISH messge processing. And i be able to this value defined from registration processing.
I expecting that vars is not shared between threads and message handling routes for var defined as $var(name). Is that not true? How i can prevent race condition between different message processing routes when two thread simultaneously change same variable?
Sergey
Hi Sergey,
$var()s live in the "private package memory" of every process, so changing that variable in one process does not affect its value in any other process.
On Sat, Jul 21, 2018 at 08:10:27PM +0300, Sergey Safarov wrote:
Hello I have faced when case when private var defined as $var(json_request) is share between different SIP messages. In my case first time this var is used from registration processing route. Then var with same name is used PUBLISH messge processing. And i be able to this value defined from registration processing.
I expecting that vars is not shared between threads and message handling routes for var defined as $var(name). Is that not true? How i can prevent race condition between different message processing routes when two thread simultaneously change same variable?
Sergey
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
You need to use an avp or an xavp instead of a var. As far as I understand it a var is tied to a particular thread (which will be reused) while avp's live in shared memory and are unique to each dialog.
On Sat, Jul 21, 2018 at 02:33:45PM -0400, John Petrini wrote:
You need to use an avp or an xavp instead of a var. As far as I understand it a var is tied to a particular thread (which will be reused) while avp's live in shared memory and are unique to each dialog.
Almost accurate. (X)AVPs are transaction-persistent, not dialog-persistent.
Dialog-persistent variables are possible, though, either by using Record-Route parameters that travel around with every in-dialog request and reply, or a more stateful approach using $dlg_var:
https://www.kamailio.org/wiki/cookbooks/5.1.x/pseudovariables#dlg_var_key
-- Alex
Thank you John and Alex for clean description.
I will test your suggestions and give feedback.
Sergey
сб, 21 июл. 2018 г. в 21:40, Alex Balashov abalashov@evaristesys.com:
On Sat, Jul 21, 2018 at 02:33:45PM -0400, John Petrini wrote:
You need to use an avp or an xavp instead of a var. As far as I
understand
it a var is tied to a particular thread (which will be reused) while
avp's
live in shared memory and are unique to each dialog.
Almost accurate. (X)AVPs are transaction-persistent, not dialog-persistent.
Dialog-persistent variables are possible, though, either by using Record-Route parameters that travel around with every in-dialog request and reply, or a more stateful approach using $dlg_var:
https://www.kamailio.org/wiki/cookbooks/5.1.x/pseudovariables#dlg_var_key
-- Alex
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 <(706)%20510-6800> / +1-800-250-5920 <(800)%20250-5920> (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users