Hi,
indeed, when a function returns with 0, Kamailio immediately ends the
processing of the packet. So that's why the unlock statement is never
executed.
I am wondering, why you are using locks at this point. That way, only
one REGISTER can be processed at the same time, since they all share
the same lock. I've never seen somebody do this before, and multiple
REGISTERs being processed in parallel should be no problem. What
problem do you try to solve by surrounding the save command with
locks?
Best Regards,
Sebastian
On Thu, Oct 12, 2017 at 6:03 PM, Vasiliy Ganchev <vancecezar(a)gmail.com> wrote:
Hi, community!
I have in my Kamailio script following block (while REGISTER processing,
after auth succeed):
.....
/* Save to usrloc */
lock("LOCATION_LOCK");
if (!save("location")) {
unlock("LOCATION_LOCK");
sl_reply_error();
exit();
}
unlock("LOCATION_LOCK");
......
According to module documentation - if "save" - failed (for any reason) - I
expected the control to be returned to the script with error code "-1"
But, there are cases - when this does not happen - which lead to deadlock
for workers processing REGISTERs (I never unlock("LOCATION_LOCK")):
- module answers with internal error - and return 0 from "save" function:
https://github.com/kamailio/kamailio/blob/master/src/modules/registrar/saveā¦
- line 1013
My use case happened due to malfunctioning device that in some moment of
time:
- send REGISTER update
- kamailio answers 200OK
- device retransmit the same REGISTER (same CSeq)
- during 20 seconds (hardcoded value in registrar module) - kamailio answers
200OK (and everything is ok)
- if retransmission continue more than 20s - kamailio answered 400 Bad
request, and did not return control to script (as a result I had no chance
to unlock("LOCATION_LOCK") from code above)
Tested it on kamailio 4.2.5 and 5.0.3.
as for me, possible solutions are:
- return -1 instead of 0 from "save" by default
- if there are some reasons not to do this - we should change documentation,
and explicitly mention that there are cases - when script execution is
stopped.
thanks in advance!
cheers
--
Sent from:
http://sip-router.1086192.n5.nabble.com/Users-f3.html
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users