summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-07-16 18:22:07 +0000
committerMatthew Jordan <mjordan@digium.com>2013-07-16 18:22:07 +0000
commit957f863dba85df0715e948f12984e81055485439 (patch)
tree07ea9d40c261cc7fb1f180fce7a290ecb0f1da80 /main
parent80dd0229f14c77db6c25fb5007bd4377631258c1 (diff)
Re-order cleanup
This patch attempts to fix some possible race conditions in shutdown of the CDR engine. It: * Adds a cleanup handler to only unsubscribe and join on stasis messages during graceful shutdown. The cleanup handler should execute before the regular atexit handler, as we want to unsubscribe for any further messages before dispatching the CDRs. * The CDRs are now locked when we dispatch them on shutdown. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/cdr.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 7791440a0..57651aeef 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -3854,10 +3854,12 @@ static int cdr_object_dispatch_all_cb(void *obj, void *arg, int flags)
struct cdr_object *cdr = obj;
struct cdr_object *it_cdr;
+ ao2_lock(cdr);
for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
cdr_object_transition_state(it_cdr, &finalized_state_fn_table);
}
cdr_object_dispatch(cdr);
+ ao2_unlock(cdr);
return 0;
}
@@ -3919,6 +3921,14 @@ static int process_config(int reload)
return 0;
}
+static void cdr_engine_cleanup(void)
+{
+ channel_subscription = stasis_unsubscribe_and_join(channel_subscription);
+ bridge_subscription = stasis_unsubscribe_and_join(bridge_subscription);
+ parking_subscription = stasis_unsubscribe_and_join(parking_subscription);
+ stasis_message_router_unsubscribe_and_join(stasis_router);
+}
+
static void cdr_engine_shutdown(void)
{
ao2_callback(active_cdrs_by_channel, OBJ_NODATA, cdr_object_dispatch_all_cb,
@@ -3930,10 +3940,6 @@ static void cdr_engine_shutdown(void)
ast_free(batch);
batch = NULL;
- channel_subscription = stasis_unsubscribe_and_join(channel_subscription);
- bridge_subscription = stasis_unsubscribe_and_join(bridge_subscription);
- parking_subscription = stasis_unsubscribe_and_join(parking_subscription);
- stasis_message_router_unsubscribe_and_join(stasis_router);
aco_info_destroy(&cfg_info);
ao2_global_obj_release(module_configs);
@@ -4035,6 +4041,7 @@ int ast_cdr_engine_init(void)
}
ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
+ ast_register_cleanup(cdr_engine_cleanup);
ast_register_atexit(cdr_engine_shutdown);
mod_cfg = ao2_global_obj_ref(module_configs);