[SR-Users] Issue with <null> and 0 when comparing vars
Joel Serrano
joel at textplus.com
Fri Sep 13 02:50:04 CEST 2019
Hello,
I'm running into what I believe a weird situation when comparing <null> to
0.
I have the following lines:
xlog("L_NOTICE", "DEBUG: sel(contact.expires)=$sel(contact.expires)
- hdr(Expires)=$hdr(Expires)\n");
if ($hdr(Expires)==0 || $sel(contact.expires)==0) {
xlog("L_NOTICE", "[end] removed user location\n");
} else {
xlog("L_NOTICE", "[end] saved user location\n");
}
I registered with 3 devices, one sends expires as header, another as
contact param, and the last uses both header AND contact param.
My surprise was this:
1- Both header and contact param:
Sep 12 19:37:48 csbc01 csbc[8036]: NOTICE: {1 4 REGISTER
02c3ea6ee623916d37532188031017c9 at 0:0:0:0:0:0:0:0} <script>: DEBUG:
sel(contact.expires)=600 - hdr(Expires)=600
Sep 12 19:37:48 csbc01 csbc[8036]: NOTICE: {1 4 REGISTER
02c3ea6ee623916d37532188031017c9 at 0:0:0:0:0:0:0:0} <script>: [end]
saved user location
2- Only contact param:
Sep 12 19:36:15 csbc01 csbc[8035]: NOTICE: {1 40629 REGISTER
f2cbaa53-eabfd633 at 84.121.150.224} <script>: DEBUG:
sel(contact.expires)=600 - hdr(Expires)=<null>
Sep 12 19:36:15 csbc01 csbc[8035]: NOTICE: {1 40629 REGISTER
f2cbaa53-eabfd633 at 84.121.150.224} <script>: [end] removed user
location
2- Only header:
Sep 12 19:29:33 csbc01 csbc[8033]: NOTICE: {1 402 REGISTER
2_1804628355 at 192.168.30.31} <script>: DEBUG:
sel(contact.expires)=<null> - hdr(Expires)=3600
Sep 12 19:29:33 csbc01 csbc[8033]: NOTICE: {1 402 REGISTER
2_1804628355 at 192.168.30.31} <script>: [end] removed user location
I can workaround the header by using is_present_hf() before comparing, I
can also probably parse the $ct to see if it has some Expires in it, but I
really want to know if my understanding is incorrect and I'm doing
something wrong or if this is a bug?
Thanks!
Joel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190912/a38a559f/attachment.html>
More information about the sr-users
mailing list