[asterisk-commits] mmichelson: trunk r112469 - in /trunk: ./ main/manager.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 2 12:36:50 CDT 2008
Author: mmichelson
Date: Wed Apr 2 12:36:49 2008
New Revision: 112469
URL: http://svn.digium.com/view/asterisk?view=rev&rev=112469
Log:
Merged revisions 112468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r112468 | mmichelson | 2008-04-02 12:36:04 -0500 (Wed, 02 Apr 2008) | 13 lines
Fix a race condition in the manager. It is possible that a new manager event
could be appended during a brief time when the manager is not waiting for input.
If an event comes during this period, we need to set an indicator that there is an
event pending so that the manager doesn't attempt to wait forever for an event that
already happened.
(closes issue #12354)
Reported by: bamby
Patches:
manager_race_condition.diff uploaded by bamby (license 430)
(comments added by me)
........
Modified:
trunk/ (props changed)
trunk/main/manager.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=112469&r1=112468&r2=112469
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Apr 2 12:36:49 2008
@@ -168,6 +168,7 @@
int send_events; /*!< XXX what ? */
struct eventqent *last_ev; /*!< last event processed. */
int writetimeout; /*!< Timeout for ast_carefulwrite() */
+ int pending_event; /*!< Pending events indicator in case when waiting_thread is NULL */
AST_LIST_ENTRY(mansession) list;
};
@@ -2822,6 +2823,11 @@
while (res == 0) {
/* XXX do we really need this locking ? */
ast_mutex_lock(&s->__lock);
+ if (s->pending_event) {
+ s->pending_event = 0;
+ ast_mutex_unlock(&s->__lock);
+ return 0;
+ }
s->waiting_thread = pthread_self();
ast_mutex_unlock(&s->__lock);
@@ -3062,6 +3068,13 @@
ast_mutex_lock(&s->__lock);
if (s->waiting_thread != AST_PTHREADT_NULL)
pthread_kill(s->waiting_thread, SIGURG);
+ else
+ /* We have an event to process, but the mansession is
+ * not waiting for it. We still need to indicate that there
+ * is an event waiting so that get_input processes the pending
+ * event instead of polling.
+ */
+ s->pending_event = 1;
ast_mutex_unlock(&s->__lock);
}
AST_LIST_UNLOCK(&sessions);
More information about the asterisk-commits
mailing list