From d1f5793b5e89426927d57cff7f6951e0c2e29d92 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 14 Feb 2018 18:20:07 +0100 Subject: fsm: allow graceful exit on FSM termination The function _osmo_fsm_inst_term() terminates all child FSMs befor it calls fi->fsm_cleanup(). This prevents the cleanup callback to perform last actions on the child FSMs (e.g. osmo_fsm_inst_unlink_parent()). - Since moving the cleanup callack to the beginning of the function would alter the termination behavior and possibly cause malfunction in already existing implementation that use OSMO fsm, a new optional callback that is called immediately at the beginning of the terminatopn process is added. Change-Id: I0fdda9fe994753f975a658c0f3fb3615949cc8bb Closes: OS#2915 --- include/osmocom/core/fsm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index bbfe3123..2c2a9961 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -78,6 +78,8 @@ struct osmo_fsm { int log_subsys; /*! human-readable names of events */ const struct value_string *event_names; + /*! graceful exit function, called at the beginning of termination */ + void (*pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause); }; /*! a single instanceof an osmocom finite state machine */ -- cgit v1.2.3