Unfortunately same result as before:

 $var(myself) = 0;
   if (uri =~ "<regex string to match>" || uri == myself){
      $var(myself) = 1;
      xlog("L_INFO", "[$ci] in uri == myself check: var myself = $var(myself)");
   }

   if (uri =~ "<regex string to match>" || is_myself("$ru")){
      $var(myself) = 1;
      xlog("L_INFO", "[$ci] in is_myself check: var myself = $var(myself)");
   }

The only log that prints out is the one that says 'in is_myself check ...'(the second if statement.)

I have verified that if there's a regular expression match then both log writes print.  Regular expression match happens when a SIP REGISTER request comes across the pipe.

Something odd is going on with the computation of  uri == myself vs is_myself("$ru").

Is there a way i can inspect what myself and uri have in them?   

Karthik




On Thu, Jul 19, 2018 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:

Hello,

things are different that one may expect from evaluation of an expression compared with other established scripting/programming languages. One thing to be sure you are aware of are the return code evaluation:

  - https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_cod

To be sure of proper behaviour, you should do:

if(uri =~ "<regex string to match>" || uri == myself) {

$var(myself) =1;

} else {

$var(myself) = 0;

}

Same with is_myself("$ru") instead of uri == myself.

Try and see if you get different values for $var(myself).

Cheers,
Daniel

On 19.07.18 19:09, Karthik Srinivasan wrote:
Yes, they are used at the very same place. here is a code snippet of where i added it for testing purposes:


route[INIT_VARS] {

$var(myself) = uri =~ "<regex string to match>" || uri == myself;
//if i print $var(myself) it prints 0 
$var(myself) = uri =~ "<regex string to match>" || is_myself("$ru");
//if i print $var(myself) it prints 1 

// in both cases above the regex part isn't supposed to match and hence correctly returns false.
...

}

route{

   route(INIT_VARS);

...
}

Thanks,

Karthik

On Thu, Jul 19, 2018 at 11:46 AM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,


On 19.07.18 18:32, Karthik Srinivasan wrote:
> Hello,
>
> Can someone explain to me why statement A returns True and statement B
> returns False.
>
> Statement A:
> is_myself("$ru")
>
> Statement B:
> uri == myself
>
>
> Isn't uri and $ru referencing the same data?   
>
> With my current config i am expecting the is_myself to return True;  i
> was expecting the same for Statement B but unfortunately it is
> returning False.
>
they are supposed to be the same in this case.

Are they used at the same place in config? Note that $ru can be changed
by different functions such as those from registrar, dispatcher, lcr, ...

Cheers,
Daniel

--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com



-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com