fsm: do not terminate child FSMs early

The function _osmo_fsm_inst_term() terminates all child FSMs befor
it calls fi->fsm_cleanup(). This prevnts the cleanup callback to
perform last actions on the child FSMs (e.g.
osmo_fsm_inst_unlink_parent()).

move the function call to  _osmo_fsm_inst_term_children() below the
call to fi->fsm->cleanup().

Change-Id: Ie89d435417306c6bf897274eabc3ed0a46485c26
---
M src/fsm.c
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/6318/2

diff --git a/src/fsm.c b/src/fsm.c
index d8751c9..dd3538f 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -509,9 +509,6 @@
        LOGPFSMSRC(fi, file, line, "Terminating (cause = %s)\n",
                   osmo_fsm_term_cause_name(cause));
 
-       _osmo_fsm_inst_term_children(fi, OSMO_FSM_TERM_PARENT, NULL,
-                                    file, line);
-
        /* delete ourselves from the parent */
        parent = fi->proc.parent;
        if (parent) {
@@ -524,6 +521,10 @@
        if (fi->fsm->cleanup)
                fi->fsm->cleanup(fi, cause);
 
+       /* terminate all children */
+       _osmo_fsm_inst_term_children(fi, OSMO_FSM_TERM_PARENT, NULL,
+                                    file, line);
+       
        LOGPFSMSRC(fi, file, line, "Freeing instance\n");
        /* Fetch parent again in case it has changed. */
        parent = fi->proc.parent;

-- 
To view, visit https://gerrit.osmocom.org/6318
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie89d435417306c6bf897274eabc3ed0a46485c26
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder

Reply via email to