mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-11 23:28:59 +00:00
Refactor CEL to avoid using the event system core
This removes usage of the event system for CEL backend data distribution and strips unused pieces out of the event system. Review: https://reviewboard.asterisk.org/r/2732/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -64,7 +64,7 @@ struct cel_config {
|
||||
AST_RWLIST_ENTRY(cel_config) list;
|
||||
};
|
||||
|
||||
static struct ast_event_sub *event_sub = NULL;
|
||||
#define CUSTOM_BACKEND_NAME "CEL Custom CSV Logging"
|
||||
|
||||
static AST_RWLIST_HEAD_STATIC(sinks, cel_config);
|
||||
|
||||
@@ -116,7 +116,7 @@ static int load_config(void)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void custom_log(const struct ast_event *event, void *userdata)
|
||||
static void custom_log(struct ast_event *event)
|
||||
{
|
||||
struct ast_channel *dummy;
|
||||
struct ast_str *str;
|
||||
@@ -167,19 +167,15 @@ static void custom_log(const struct ast_event *event, void *userdata)
|
||||
|
||||
static int unload_module(void)
|
||||
{
|
||||
if (event_sub) {
|
||||
event_sub = ast_event_unsubscribe(event_sub);
|
||||
}
|
||||
|
||||
if (AST_RWLIST_WRLOCK(&sinks)) {
|
||||
event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, "CEL Custom CSV Logging",
|
||||
NULL, AST_EVENT_IE_END);
|
||||
ast_log(LOG_ERROR, "Unable to lock sink list. Unload failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
free_config();
|
||||
AST_RWLIST_UNLOCK(&sinks);
|
||||
ast_cel_backend_unregister(CUSTOM_BACKEND_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -193,8 +189,9 @@ static enum ast_module_load_result load_module(void)
|
||||
load_config();
|
||||
AST_RWLIST_UNLOCK(&sinks);
|
||||
|
||||
event_sub = ast_event_subscribe(AST_EVENT_CEL, custom_log, "CEL Custom CSV Logging",
|
||||
NULL, AST_EVENT_IE_END);
|
||||
if (ast_cel_backend_register(CUSTOM_BACKEND_NAME, custom_log)) {
|
||||
return AST_MODULE_LOAD_FAILURE;
|
||||
}
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user