diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c index e3c682b604..58d7a4f5f5 100644 --- a/cel/cel_pgsql.c +++ b/cel/cel_pgsql.c @@ -334,11 +334,12 @@ ast_log_cleanup: 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_RWLIST_WRLOCK(&psql_columns); if (conn) { PQfinish(conn); conn = NULL;