<div dir="ltr">My experience with app_perl is that global variables are not shared between processes.  So if you have 10 kamailio processes you would have 10 different %hash with different values.  So it is thread safe, but perhaps isn't what you want.<br><br>Torrey</div><div class="gmail_extra"><br><div class="gmail_quote">On 13 October 2016 at 23:15, Alex Balashov <span dir="ltr"><<a href="mailto:abalashov@evaristesys.com" target="_blank">abalashov@evaristesys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I meant a global Perl variable -- one that would persist in a persistent interpreter. Specifically, a "package variable" of this type:<br>
<br>
   our %hash = ();<div class="HOEnZb"><div class="h5"><br>
<br>
On 10/13/2016 04:26 PM, Daniel-Constantin Mierla wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
is it about a global variable defined inside the perl script or you mean<br>
kamailio.cfg variables? The terminology you used might be clear for Perl<br>
guys, but as I am not one, I want to clarify it...<br>
<br>
As generic remarks -- kamailio is multi-process application, so each<br>
child is a process, not a thread. Each process has its own private<br>
memory space, so a global kamailio.cfg variable such as $var(x) is<br>
defined in each process and each process has access to the one specific<br>
to it. There are shared memory variables, like $shv(z) that all<br>
processes can access and change, requiring synchronization to avoid races.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<br>
On 13/10/16 19:13, Alex Balashov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Given the presence of a global (e.g. "our") package variable in an<br>
embedded Perl script used through app_perl, is there any implicit<br>
thread safety?<br>
<br>
That is to say, can a Perl function invoked by one SIP worker reset<br>
the value of a global while another instance of the function invoked<br>
by a different SIP worker is accessing it?<br>
<br>
And if so, is it safe to use generic perlthr locking to avoid this?<br>
<br>
Thanks!<br>
<br>
-- Alex<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
-- <br></div></div><span class="im HOEnZb">
Alex Balashov | Principal | Evariste Systems LLC<br>
<br>
Tel: +1-706-510-6800 (direct) / +1-800-250-5920 (toll-free)<br>
Web: <a href="http://www.evaristesys.com/" rel="noreferrer" target="_blank">http://www.evaristesys.com/</a>, <a href="http://www.csrpswitch.com/" rel="noreferrer" target="_blank">http://www.csrpswitch.com/</a><br>
<br></span><div class="HOEnZb"><div class="h5">
______________________________<wbr>_________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" rel="noreferrer" target="_blank">http://lists.sip-router.org/cg<wbr>i-bin/mailman/listinfo/sr-dev</a><br>
</div></div></blockquote></div><br></div>