[asterisk-dev] [Code Review] Fix a deadlock in agents occuring due to trying to lock a channel while having a lock on the pvt.

Mark Michelson reviewboard at asterisk.org
Wed Feb 1 15:09:37 CST 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1708/#review5371
-----------------------------------------------------------


I think that because of your change to agent_hangup(), there's a new potential deadlock. Allow me to explain:

The competing threads are the agent's channel thread and the thread that processes, say, the AMI agents action.

First, the channel thread issues a hangup, so agent_hangup is called with the channel locked.
Meanwhile, someone issues the Agents action and grabs the list lock for the agents.
The hangup now wants to grab the list lock, but cannot until the AMI action is completed.
So now, the AMI thread does its business where it grabs the pvt->owner, unlocks, and then attempts to grab the channel lock.

We now have a deadlock because the AMI thread has the list lock and is trying to get the channel lock, and the channel thread has the channel lock and is trying to get the list lock.

- Mark


On Feb. 1, 2012, 2:20 p.m., jrose wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1708/
> -----------------------------------------------------------
> 
> (Updated Feb. 1, 2012, 2:20 p.m.)
> 
> 
> Review request for Asterisk Developers, Mark Michelson, rmudgett, and Matt Jordan.
> 
> 
> Summary
> -------
> 
> Also adds locking to a number of other functions which are calling ast_bridged_channel (which is documented as requiring a lock for safe running, which was the purpose of irroot's original locking patch in action_agents.
> 
> Unlike the other patch on reviewboard right now, this opts to enforce locking order instead of using deadlock avoidance.
> 
> Celebrity endorsement: "This looks incredibly sane to me." - MMichelson
> 
> 
> This addresses bug ASTERISK-19285.
>     https://issues.asterisk.org/jira/browse/ASTERISK-19285
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/channels/chan_agent.c 353685 
> 
> Diff: https://reviewboard.asterisk.org/r/1708/diff
> 
> 
> Testing
> -------
> 
> Not much I'm afraid to say. I can't reproduce the issue since it involves real world use over a period of time.  I'll ask Alex Villacís Lasso to give it a shot though.
> 
> 
> Thanks,
> 
> jrose
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120201/b50a9c2f/attachment.htm>


More information about the asterisk-dev mailing list