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