[Asterisk-Dev] Problem transferring queue agents
Tony Mountifield
tony at softins.clara.co.uk
Mon Aug 22 07:50:51 MST 2005
I'm in the middle of trawling through the code to fix a problem, and
wondered if anyone here could add any insight while I'm looking.
The scenario is that an Agent logs in with AgentCallbackLogin, and
then subsequently takes a call. As part of the handling of that call
while it is in progress, the caller (e.g. SIP/2002-abcd) and the
agent (e.g. Agent/1001) channels are both redirected to a meetme
extension using the manager API with ExtraChannel.
The problem is that after the agent subsequently hangs up, an attempt
to pass another call to that agent causes a deadlock on the agent's
app_lock mutex.
What I've discovered so far:
1. When the agent takes the first call, the app_lock mutex in the
agent's agent_pvt is locked by the calling thread.
2. When the Redirect happens, the Agent is masqueraded in the function
ast_async_goto, and consequently ends up being owned by a different
thread.
3. When the agent finally hangs up (from the meetme room), agent_hangup
is unable to unlock app_lock, because it is a different thread from that
which locked it:
chan_agent.c line 773 (agent_hangup): Error releasing mutex: Operation not permitted
4. The mutex remains locked, and next time a call is passed to the agent,
it deadlocks trying to acquire app_lock:
chan_agent.c line 921 (agent_new): Deadlock? waited 5 sec for mutex '&p->app_lock'?
(null) line 0 ((null)): '&p->app_lock' was locked here.
What needs to happen:
When the channel is masqueraded in ast_async_goto, I assume the agent_pvt
structure is moved across to the new channel. At this time, the app_lock
needs to be unlocked by the originating thread and locked by the receiving
thread, also without any other queued call claiming it. This is what I am
currently trying to work out how to do, and any comments or suggestions
would be very welcome!
Cheers
Tony
--
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org
More information about the asterisk-dev
mailing list