[asterisk-bugs] [Asterisk 0012354]: [patch] Race condition in manager interface.

noreply at bugs.digium.com noreply at bugs.digium.com
Wed Apr 2 11:52:28 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=12354 
====================================================================== 
Reported By:                bamby
Assigned To:                putnopvut
====================================================================== 
Project:                    Asterisk
Issue ID:                   12354
Category:                   Core/ManagerInterface
Reproducibility:            random
Severity:                   major
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.18 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             04-02-2008 08:48 CDT
Last Modified:              04-02-2008 11:52 CDT
====================================================================== 
Summary:                    [patch] Race condition in manager interface.
Description: 
I use the manager interface (not HTTP) to identify the state of the channel
and state changes are to be detected as soon as possible. However I
experienced strange random delays that could last for several seconds
especially if the system had small load.

I've made investigation of the issue and found a cause of the problem. An
events get reported via manager_event() function which appends the event to
event queue and tries to inform the manager session thread about new event.
Notification is done via pthread_kill(s->waiting_thread, SIGURG) call in
order to interrupt the poll() call in get_input() function. But the problem
is that the waiting_thread field has valid value only during the poll()
call. Immediately after the poll() the waiting_thread is cleared and stays
NULL until next poll(). So if an event comes at the instant when
waiting_thread is AST_PTHREAD_NULL then this event has a good chance to
stay unnoticed until next event or input from client.

I've added a field to the struct mansession that act as a pending event
indicator when the waiting_thread is NULL. This works pretty well for me.
====================================================================== 

---------------------------------------------------------------------- 
 putnopvut - 04-02-08 11:52  
---------------------------------------------------------------------- 
Good find, bamby. I took a look at your patch and it makes good sense to
me. I'll get this committed ASAP. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
04-02-08 11:52  putnopvut      Note Added: 0084934                          
======================================================================




More information about the asterisk-bugs mailing list