[asterisk-commits] jpeeler: trunk r243986 - /trunk/main/manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 28 16:37:20 CST 2010


Author: jpeeler
Date: Thu Jan 28 16:37:15 2010
New Revision: 243986

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=243986
Log:
Optimization to manager events.

When potentially sending manager events, return immediately if there are no
sessions or hooks. Also, avoid locking the hooks list if it is empty.

(issue #16455)
Reported by: atis
Patches: 
      manager_hooks_trunk.patch uploaded by atis (license 242)

Modified:
    trunk/main/manager.c

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=243986&r1=243985&r2=243986
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Thu Jan 28 16:37:15 2010
@@ -4286,6 +4286,10 @@
 	struct ast_str *buf;
 	int i;
 
+	if (!sessions && AST_RWLIST_EMPTY(&manager_hooks)) {
+		return 0;
+	}
+	
 	if (!(buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE))) {
 		return -1;
 	}
@@ -4343,11 +4347,13 @@
 		ao2_iterator_destroy(&i);
 	}
 
-	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 (!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