[asterisk-commits] kmoore: branch 12 r402838 - /branches/12/main/cel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Nov 15 08:36:05 CST 2013
Author: kmoore
Date: Fri Nov 15 08:35:58 2013
New Revision: 402838
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402838
Log:
CEL: Fix crash when using CELGenUserEvent
This fixes a crash when CELGenUserEvent is called from the dialplan
while CEL is disabled. Currently, CEL does not create its topics and
forwards if it is not enabled and external entities may depend on
these topics blindly since they should always be available. This patch
breaks up route creation and topic/forward creation such that the CEL
topics and forwards will always exist while the router and its
associated routes will be torn down and recreated as necessary.
(closes issue ASTERISK-22799)
Review: https://reviewboard.asterisk.org/r/3010/
Reported by: Matt Jordan
Modified:
branches/12/main/cel.c
Modified: branches/12/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/cel.c?view=diff&rev=402838&r1=402837&r2=402838
==============================================================================
--- branches/12/main/cel.c (original)
+++ branches/12/main/cel.c Fri Nov 15 08:35:58 2013
@@ -1363,11 +1363,14 @@
cel_report_event(localone, AST_CEL_LOCAL_OPTIMIZE, NULL, extra, NULL);
}
-static void destroy_subscriptions(void)
+static void destroy_routes(void)
{
stasis_message_router_unsubscribe_and_join(cel_state_router);
cel_state_router = NULL;
-
+}
+
+static void destroy_subscriptions(void)
+{
ao2_cleanup(cel_aggregation_topic);
cel_aggregation_topic = NULL;
ao2_cleanup(cel_topic);
@@ -1381,6 +1384,7 @@
static void ast_cel_engine_term(void)
{
+ destroy_routes();
destroy_subscriptions();
aco_info_destroy(&cel_cfg_info);
@@ -1400,8 +1404,6 @@
*/
static int create_subscriptions(void)
{
- int ret = 0;
-
cel_aggregation_topic = stasis_topic_create("cel_aggregation_topic");
if (!cel_aggregation_topic) {
return -1;
@@ -1439,6 +1441,16 @@
if (!cel_cel_forwarder) {
return -1;
}
+
+ return 0;
+}
+
+/*!
+ * \brief Create the Stasis message router and routes for CEL
+ */
+static int create_routes(void)
+{
+ int ret = 0;
cel_state_router = stasis_message_router_create(cel_aggregation_topic);
if (!cel_state_router) {
@@ -1550,7 +1562,11 @@
}
}
- if (ast_cel_check_enabled() && create_subscriptions()) {
+ if (create_subscriptions()) {
+ return -1;
+ }
+
+ if (ast_cel_check_enabled() && create_routes()) {
return -1;
}
@@ -1570,11 +1586,11 @@
is_enabled = ast_cel_check_enabled();
if (!was_enabled && is_enabled) {
- if (create_subscriptions()) {
+ if (create_routes()) {
return -1;
}
} else if (was_enabled && !is_enabled) {
- destroy_subscriptions();
+ destroy_routes();
}
ast_verb(3, "CEL logging %sabled.\n", is_enabled ? "en" : "dis");
@@ -1636,9 +1652,9 @@
is_enabled = ast_cel_check_enabled();
if (!was_enabled && is_enabled) {
- create_subscriptions();
+ create_routes();
} else if (was_enabled && !is_enabled) {
- destroy_subscriptions();
+ destroy_routes();
}
}
}
More information about the asterisk-commits
mailing list