summaryrefslogtreecommitdiff
path: root/cel/cel_pgsql.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-08-17 14:46:44 +0000
committerKinsey Moore <kmoore@digium.com>2013-08-17 14:46:44 +0000
commitd7f1f3127084e4b7b204141c0b40c28c327f74b0 (patch)
treedf54e4afb05375633f67c2cefe694eddbf2f146e /cel/cel_pgsql.c
parent59753b1ea10a83ea770c35b24cd443620913349c (diff)
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
Diffstat (limited to 'cel/cel_pgsql.c')
-rw-r--r--cel/cel_pgsql.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c
index 0a393a6ca..5ba5b9972 100644
--- a/cel/cel_pgsql.c
+++ b/cel/cel_pgsql.c
@@ -58,6 +58,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define DATE_FORMAT "%Y-%m-%d %T.%6q"
+#define PGSQL_BACKEND_NAME "CEL PGSQL backend"
+
static char *config = "cel_pgsql.conf";
static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL;
static int connected = 0;
@@ -73,7 +75,6 @@ AST_MUTEX_DEFINE_STATIC(pgsql_lock);
static PGconn *conn = NULL;
static PGresult *result = NULL;
-static struct ast_event_sub *event_sub = NULL;
struct columns {
char *name;
@@ -113,7 +114,7 @@ static AST_RWLIST_HEAD_STATIC(psql_columns, columns);
} \
} while (0)
-static void pgsql_log(const struct ast_event *event, void *userdata)
+static void pgsql_log(struct ast_event *event)
{
struct ast_tm tm;
char timestr[128];
@@ -346,10 +347,7 @@ static int my_unload_module(void)
{
struct columns *current;
AST_RWLIST_WRLOCK(&psql_columns);
- if (event_sub) {
- event_sub = ast_event_unsubscribe(event_sub);
- event_sub = NULL;
- }
+ ast_cel_backend_unregister(PGSQL_BACKEND_NAME);
if (conn) {
PQfinish(conn);
conn = NULL;
@@ -561,9 +559,7 @@ static int my_load_module(int reload)
process_my_load_module(cfg);
ast_config_destroy(cfg);
- event_sub = ast_event_subscribe(AST_EVENT_CEL, pgsql_log, "CEL PGSQL backend", NULL, AST_EVENT_IE_END);
-
- if (!event_sub) {
+ if (ast_cel_backend_register(PGSQL_BACKEND_NAME, pgsql_log)) {
ast_log(LOG_WARNING, "Unable to subscribe to CEL events for pgsql\n");
return AST_MODULE_LOAD_DECLINE;
}