[SR-Users] unexpected behavior of save from registrar module

Vasiliy Ganchev vancecezar at gmail.com
Thu Oct 12 18:03:22 CEST 2017


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.c
- 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



More information about the sr-users mailing list