[asterisk-commits] file: trunk r190586 - /trunk/main/manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 27 10:18:52 CDT 2009


Author: file
Date: Mon Apr 27 10:18:47 2009
New Revision: 190586

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=190586
Log:
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

Modified:
    trunk/main/manager.c

Modified: trunk/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/manager.c?view=diff&rev=190586&r1=190585&r2=190586
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Mon Apr 27 10:18:47 2009
@@ -3511,7 +3511,6 @@
 	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 @@
 	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;
-		}
-		ao2_unlock(session);
-		unref_mansession(session);
+	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);
+		}
 	}
 
 	AST_RWLIST_RDLOCK(&manager_hooks);




More information about the asterisk-commits mailing list