mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-25 22:18:07 +00:00
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) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243986 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4286,6 +4286,10 @@ int __ast_manager_event_multichan(int category, const char *event, int chancount
|
||||
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 @@ int __ast_manager_event_multichan(int category, const char *event, int chancount
|
||||
ao2_iterator_destroy(&i);
|
||||
}
|
||||
|
||||
AST_RWLIST_RDLOCK(&manager_hooks);
|
||||
AST_RWLIST_TRAVERSE(&manager_hooks, hook, list) {
|
||||
hook->helper(category, event, ast_str_buffer(buf));
|
||||
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);
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&manager_hooks);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user