[SR-Users] Important problem with this test : if ($var(i:maxRangeInx)==$null)

Daniel-Constantin Mierla miconda at gmail.com
Mon Mar 27 15:31:10 CEST 2017


Hello,

$var(...) don't hold null values, they start initialed to 0 and they are
reset to 0 (when assigning $null to them) -- this is the design from the
beginning which brings benefits in many situation when one doesn't get a
chance to init.

If you want a similar variable that works with null, then use $vn(...):

  -
https://www.kamailio.org/wiki/cookbooks/5.0.x/pseudovariables#vn_name_-_private_memory_variables_null

Cheers,
Daniel


On 27/03/2017 15:22, Ginhoux, Patrick wrote:
>
> Hi,
>
>  
>
> I’m continue my job to ‘migrate’ my 3.3.1 kamailio.cfg script on a
> RHEL 6.2 server to the 5.0.x kamailio version on a RHEL 7.1 server,
> and I encounter a major problem with the ‘== $null’ test in the script.
>
>  
>
> My original script (3.3.1) contains this sequence :
>
>  
>
>         $var(i:rangeInx)=0;
>
>         $var(i:maxRangeInx) = $sht(mbxrangeHash=>"maxrange");
>
>         xlog(" imbxRangeInx value before test : '$var(i:maxRangeInx)' ");
>
>         if ($var(i:maxRangeInx)==$null) {
>
>                 $var(i:maxRangeInx)=99;
>
>         }
>
>         xlog(" imbxRangeInx after test : '$var(i:maxRangeInx)' ");
>
>  
>
> èThe results are :
>
> imbxRangeInx value before test : ‘0’
>
> imbxRangeInx value after test : ‘99’
>
>  
>
> I run the same script on my new server and I get ‘0’ before and after
> the test.
>
>  
>
> I attempted another kind of test to try to figure out where the
> problem is. So I write the simple test (with kamailio 5.0.x) :
>
>  
>
>         $var(i:rangeInx)=0;
>
>         $var(i:maxRangeInx) = $sht(mbxrangeHash=>"maxrange");
>
>         $var(toto) = $null;
>
>         if ($var(toto) == $null)
>
>                 xlog ("toto true");
>
>         else
>
>                 xlog ("toto false");
>
>  
>
> The result I got is always ‘toto false’.
>
>  
>
> So it appears to me that the test ‘== $null’ doens’ that gives a good
> result with kamailio 3.3.1, doesn’t return the same with kamailio 5.0.x.
>
>  
>
> That is a major issue for me and it let me confused about the
> possibility to move to kamailio 5.0.x.
>
>  
>
> Have people an idea / explanation, why this issue ?
>
>  
>
> Cordialement
>
> Patrick GINHOUX
>
>  
>
>
>
> _______________________________________________
> 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

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com
Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20170327/1c25f2ec/attachment.html>


More information about the sr-users mailing list