[MERGED] libosmocore[master]: fsm: call 'onenter' as last step of a state change

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Jul 10 13:19:08 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: fsm: call 'onenter' as last step of a state change
......................................................................


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
---
M src/fsm.c
1 file changed, 4 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/fsm.c b/src/fsm.c
index 8fedae2..6649b09 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -323,14 +323,15 @@
 	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;
 }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia45a1f3279e702028250e10dc54b2d46a4039905
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list