summaryrefslogtreecommitdiffstats
path: root/src/fsm.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-07-10 15:09:43 +0200
committerHarald Welte <laforge@gnumonks.org>2016-07-10 15:09:43 +0200
commit673018fed99aab80c3ac23c95f568ff0bf272f60 (patch)
treefb7e19063e1d542a9cabf652929bc6ac17f14f93 /src/fsm.c
parentf5f773f0130e1f61b84636f7aeb6e17f5140fd25 (diff)
fsm: call 'onenter' as last step of a state change
This is useful to allow the user to terinate the fsm from the onenter() callback. Change-Id: Ia45a1f3279e702028250e10dc54b2d46a4039905
Diffstat (limited to 'src/fsm.c')
-rw-r--r--src/fsm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fsm.c b/src/fsm.c
index 8fedae26..6649b091 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -323,14 +323,15 @@ int osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state,
LOGPFSM(fi, "state_chg to %s\n", osmo_fsm_state_name(fsm, new_state));
fi->state = new_state;
- if (st->onenter)
- st->onenter(fi, old_state);
-
if (timeout_secs) {
fi->T = T;
osmo_timer_schedule(&fi->timer, timeout_secs, 0);
}
+ /* Call 'onenter' last, user might terminate FSM from there */
+ if (st->onenter)
+ st->onenter(fi, old_state);
+
return 0;
}