[asterisk-commits] jpeeler: branch 1.6.2 r243989 - /branches/1.6.2/main/manager.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 28 16:57:03 CST 2010
Author: jpeeler
Date: Thu Jan 28 16:56:59 2010
New Revision: 243989
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=243989
Log:
Ensure manager hooks are executed when there are no manager sessions.
Conditional expanded to check for hooks before aborting manager event
processing. The other two changes are just optimizations.
(closes issue #16455)
Reported by: atis
Patches:
manager_hooks_16.patch uploaded by atis (license 242)
Tested by: atis
Modified:
branches/1.6.2/main/manager.c
Modified: branches/1.6.2/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/manager.c?view=diff&rev=243989&r1=243988&r2=243989
==============================================================================
--- branches/1.6.2/main/manager.c (original)
+++ branches/1.6.2/main/manager.c Thu Jan 28 16:56:59 2010
@@ -3308,8 +3308,8 @@
struct timeval now;
struct ast_str *buf;
- /* Abort if there aren't any manager sessions */
- if (!num_sessions)
+ /* Abort if there are neither any manager sessions nor hooks */
+ if (!num_sessions && AST_RWLIST_EMPTY(&manager_hooks))
return 0;
if (!(buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE)))
@@ -3343,28 +3343,32 @@
append_event(ast_str_buffer(buf), category);
- /* Wake up any sleeping sessions */
- AST_LIST_LOCK(&sessions);
- AST_LIST_TRAVERSE(&sessions, session, list) {
- ast_mutex_lock(&session->__lock);
- if (session->waiting_thread != AST_PTHREADT_NULL)
- pthread_kill(session->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.
- */
- session->pending_event = 1;
- ast_mutex_unlock(&session->__lock);
- }
- AST_LIST_UNLOCK(&sessions);
-
- AST_RWLIST_RDLOCK(&manager_hooks);
- AST_RWLIST_TRAVERSE(&manager_hooks, hook, list) {
- hook->helper(category, event, ast_str_buffer(buf));
- }
- AST_RWLIST_UNLOCK(&manager_hooks);
+ if (num_sessions) {
+ /* Wake up any sleeping sessions */
+ AST_LIST_LOCK(&sessions);
+ AST_LIST_TRAVERSE(&sessions, session, list) {
+ ast_mutex_lock(&session->__lock);
+ if (session->waiting_thread != AST_PTHREADT_NULL)
+ pthread_kill(session->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.
+ */
+ session->pending_event = 1;
+ ast_mutex_unlock(&session->__lock);
+ }
+ AST_LIST_UNLOCK(&sessions);
+ }
+
+ if (!AST_RWLIST_EMPTY(&manager_hooks)) {
+ AST_RWLIST_RDLOCK(&manager_hooks);
+ AST_RWLIST_TRAVERSE(&manager_hooks, hook, list) {
+ hook->helper(category, event, ast_str_buffer(buf));
+ }
+ AST_RWLIST_UNLOCK(&manager_hooks);
+ }
return 0;
}
More information about the asterisk-commits
mailing list