[SR-Users] Thread safety of shared variables

Alex Balashov abalashov at evaristesys.com
Wed Nov 19 17:21:41 CET 2014


Thanks, it was actually increment I was interested in. 

Can one get around it with an intermediate variable? 

$var(y) = $shv(x);
$shv(x) = $var(y) + 1;

I would just use a lock(), but I'm afraid that it will serialise message processing too much at high volume, due to the blocking. 


On 19 November 2014 01:23:14 GMT-05:00, Daniel-Constantin Mierla <miconda at gmail.com> wrote:
>For what kind of operation?
>
>Reading or setting the value are safe, but updating it with its own
>value used in an expression is not.
>
>Safe:
>
>xlog("value is $sht(x)\n");
>$sht(x) = 1;
>
>Race:
>
>$sht(x) = $sht(x) + 1;
>
>Cheers,
>Daniel
>
>On 19/11/14 00:27, Alex Balashov wrote:
>> Does setting $shv()s in script require lock()ing, or is it inherently
>> thread-safe?
>>
>> Thanks!
>>
>
>-- 
>Daniel-Constantin Mierla
>http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
>Kamailio Advanced Training, Nov 24-27, Berlin - http://www.asipto.com
>
>
>_______________________________________________
>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>sr-users at lists.sip-router.org
>http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

--
Sent from my Nexus 10, with all the figments of autocorrect that might imply.

Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Decatur, GA 30030
United States
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20141119/f9b6579d/attachment.html>


More information about the sr-users mailing list