summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2009-04-27 15:18:47 +0000
committerJoshua Colp <jcolp@digium.com>2009-04-27 15:18:47 +0000
commit68a9f7aca14dbdade7e53c22f0889228d06c24e6 (patch)
treeed2597f7f6668028856ac73adc4daac0c32b27ec
parent3b68be6aaa9300c6c9f9836ebef73dfc90dba3bd (diff)
Fix a bug where we tried to send events out when no sessions container was present.
This commit stops a warning message (user_data is NULL) from getting output when manager events get sent before manager is initialized. This happens because manager is initialized *after* modules are loaded and the act of loading modules triggers manager events. (issue #14974) Reported by: pj git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190586 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--main/manager.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/main/manager.c b/main/manager.c
index 09e3c764c..a43f5518b 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3511,7 +3511,6 @@ int __manager_event(int category, const char *event,
va_list ap;
struct timeval now;
struct ast_str *buf;
- struct ao2_iterator i;
if (!(buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE))) {
return -1;
@@ -3546,21 +3545,24 @@ int __manager_event(int category, const char *event,
append_event(ast_str_buffer(buf), category);
/* Wake up any sleeping sessions */
- i = ao2_iterator_init(sessions, 0);
- while ((session = ao2_iterator_next(&i))) {
- ao2_lock(session);
- 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;
+ if (sessions) {
+ struct ao2_iterator i;
+ i = ao2_iterator_init(sessions, 0);
+ while ((session = ao2_iterator_next(&i))) {
+ ao2_lock(session);
+ 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;
+ }
+ ao2_unlock(session);
+ unref_mansession(session);
}
- ao2_unlock(session);
- unref_mansession(session);
}
AST_RWLIST_RDLOCK(&manager_hooks);