[asterisk-dev] channel_walk_locked possible bug / possible fix?
Steve Davies
davies147 at gmail.com
Thu Nov 16 06:25:30 MST 2006
Hi,
I have been looking in an issue where we occasionally get deadlocked
channels on our asterisk systems, which are visible through the
logging of messages such as:
...
Zap/56-1(isdn-external s 1) Up Bridged Call SIP/306-5a66
45 active channel(s)
WARNING[13001]: channel.c:537 ast_channel_walk_locked: Avoided
deadlock for 'SIP/306-5a66', 10 retries!
In the above example, the channel SIP/306-5a66 cannot be seen in any
show commands, and the "Avoided deadlock" message appears periodically
in the logs during normal usage.
I have not found anything significant in the bug tracker, but I have a
theory, and would like to air it here for comments:
'ast_channel_walk_locked' calls 'channel_find_locked' with *prev set
to the current list position. 'channel_find_locked' then steps forward
through the list by one position, and tries to lock the next channel
list entry. If the lock fails 10 times, then the above warning is
printed, and NULL is returned.
Assuming that some code is looping through repeated calls to
'ast_channel_walk_locked' until NULL is returned (I found at least 6
cases of this in the 1.2.13 codebase), returning NULL at this point
implies that the end of the list has been reached, which may not be
true! It is also conceivable that the deadlock will not clear until
some processing on a channel later in the list has been completed.
This processing can now never happen.
I am attaching a patch which causes the deadlocked channel to be
skipped rather than returning NULL in this case. If people do not find
this suggestion laughably silly, I will add it to the bug tracker.
(As an aside, am I mistaken, or does
'ast_walk_channel_by_name_prefix_locked' never use the provided 'name'
value, and is therefore identical to 'ast_channel_walk_locked'? Not
that its important as the method is never used :) )
Kind regards,
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chan.patch
Type: text/x-patch
Size: 742 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20061116/ec6ccb54/chan-0001.bin
More information about the asterisk-dev
mailing list