[Kamailio-Devel] race condition

Zappasodi Daniele Daniele.Zappasodi at seltatel.it
Thu Apr 23 10:34:26 CEST 2009

I have a problem with a race condition with the reply and retransmission.
Sometimes Openser (I'm still working with 1.3.x version) ignores the provisional reply and tears down the call after the fr_timer.
This happens only in a particulary conditions: 
I have a short value for fr_timer (5 sec);
the reply arrives very fast (I have gateway and proxy on the same box).

In this situation can happen that a child sends the INVITE (SEND_BUFFER in t_forward_nonack) and it is suspended by the scheduler before it can execute start_retr. 
Another child get the reply.
When the first child executes start_retr it sends immediately a retransmission for the INVITE and after 5 seconds (the fr_timer) it tears down the call with CANCEL, because it ignores the reply.

I know that this is a very improbable condition (even if I encountered it), but if you want to fix it, it should be easy to solve: in t_forward_nonack, before start_retr, it should be tested if another child has already received a reply. 
Something like this (t_fwd.c on head):

@@ -719,7 +719,10 @@
-                       start_retr( &t->uac[i].request );
+                       if(p_msg->REQ_METHOD==METHOD_INVITE && t->uac[i].last_received>=100)
+                               LM_DBG("Last received %d\n",t->uac[i].last_received);
+                       else
+                               start_retr( &t->uac[i].request );

The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this 
by anyone else is unauthorized. If you are not the intended 
recipient, any
disclosure, copying, or distribution of the message, or any action 
omission taken by you in reliance on it, is prohibited and may be 
Please immediately contact the sender if you have received this 
message in error.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3188 bytes
Desc: not available
Url : http://lists.kamailio.org/pipermail/devel/attachments/20090423/dfb64313/attachment.bin 

More information about the Devel mailing list