[asterisk-dev] [Code Review] Queue SIP requests/responses that cannot be immediately processed.

Klaus Darilion klaus.mailinglists at pernau.at
Wed Jan 7 05:34:04 CST 2009


Interesting. I recently did some tests with Asterisk 1.4.22 and 
experienced channel lock problems quite often - no special processing, 
just forwarding an incoming SIP call with SIP.

[Dec 30 16:35:36] DEBUG[876] chan_sip.c: = Found Their Call ID: 
1541000556838211293562be778ddcec at 81.16.153.184 Their Tag  Our tag: 
as7e355cbb
[Dec 30 16:35:36] DEBUG[876] chan_sip.c: Failed to grab owner channel 
lock, trying again. (SIP call 
1541000556838211293562be778ddcec at 81.16.153.184)
[Dec 30 16:35:36] DEBUG[876] chan_sip.c: = Found Their Call ID: 
1541000556838211293562be778ddcec at 81.16.153.184 Their Tag  Our tag: 
as7e355cbb
[Dec 30 16:35:36] DEBUG[876] chan_sip.c: Failed to grab owner channel 
lock. (SIP call 1541000556838211293562be778ddcec at 81.16.153.184)
[Dec 30 16:35:36] ERROR[876] chan_sip.c: We could NOT get the channel 
lock for SIP/gw-asterisk-09c9db18!
[Dec 30 16:35:36] ERROR[876] chan_sip.c: SIP transaction failed: 
1541000556838211293562be778ddcec at 81.16.153.184


regards
klaus




Kevin Fleming schrieb:
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.digium.com/r/117/
> -----------------------------------------------------------
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> When a request or response arrives in sipsock_read(), and the associated sip_pvt has an ast_channel (owner), sipsock_read() attempts to obtain the channel's lock. However, this can fail if the channel is locked by another thread, which could be the case for an extended period of time (multiple microseconds, if not longer). sipsock_read() tries to work around this issue by retrying (up to 100 times) to obtain the lock, but if it still fails, the incoming message is unceremoniously dropped, under the assumption that the other endpoint will retransmit if needed. If this occurs, a message is logged to the console.
> 
> As it turns out, this is a rather common occurrence, because when an incoming call is answered via the diaplan, a '200 OK' is sent to the UAC that originated the call, which will likely result in an *immediate* 'ACK' response from the UAC. However, the channel answer process might not actually be completed, especially if it involves creation of translator paths, and so the 'ACK' is dropped, generating an error message and requiring the retransmission of both the '200 OK' and the 'ACK'.
> 
> This commit would change sipsock_read() to instead queue requests that cannot be processed immediately; queued requests will be processed either when a timer expires (no more than 10 milliseconds later), or when another request arrives and sipsock_read() was able to obtain the channel lock. In either situation, requests will be processed in the order they were received.
> 
> 
> Diffs
> -----
> 
>   /branches/1.4/channels/chan_sip.c 167370 
> 
> Diff: http://reviewboard.digium.com/r/117/diff
> 
> 
> Testing
> -------
> 
> A small amount of testing was done on Shaun Ruffell's transcoder test system, which was exhibiting this problem for every single call that required creation of a transcoder-based translation path. These changes solved his issues regarding SIP message loss and retransmission and did not exhibit any negative effects.
> 
> 
> Thanks,
> 
> Kevin
> 
> 
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
> 
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev



More information about the asterisk-dev mailing list