[SR-Users] Usleep on Reply

Alex Balashov abalashov at evaristesys.com
Mon Jul 31 23:22:40 CEST 2017


Hi Nicolas,

The sleep functions block an entire SIP worker thread, of which there
is a small number. While it's blocked, new incoming SIP messages will be
picked up by other SIP workers. You can read more about how this works
here (shameless plug, it's my article):

http://blog.csrpswitch.com/tuning-kamailio-for-high-throughput-and-performance/

In general, most ideas that rely on these functions are bad ones for the
reasons explained in the article. 

If you want to check whether replies were received in a particular
order, just use flags, which are transaction-persistent, in an
onreply_route. That is, you can do something like:

  #!define FL_183_RECEIVED 1

  onreply_route[REPLY] {
     if(t_check_status("183")) 
        setflag(FL_183_RECEIVED);

     if(t_check_status("180")) {
        if(isflagset(FL_183_RECEIVED)) { 
           xlog("[$ci] 180 received after 183! The horror!\n");
           ...
        } 
     }

These flags can be accessed from any route that is called in connection
with the given transaction.

You can also used AVPs or XAVPs if you need to keep some more
sophisticated state associated with these messages, of course.

-- Alex 

-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/



More information about the sr-users mailing list