[PATCH] libosmocore[master]: fsm: term: get parent pointer as late as possible

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Dec 21 14:32:19 UTC 2016


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1476

to look at the new patch set (#2).

fsm: term: get parent pointer as late as possible

During FSM instance termination, fetch the parent pointer every time just
before using it, in case the child termination or cleanup callback wish to
change anything about the parent, e.g. to prevent event dispatch.

This patch was created to try and fix a problem that was in the end solved
differently. There is no actual need or use case for this at the moment, but it
generally makes sense to get the parent pointer as late as possible.

Change-Id: I999d7f29ba10281d4005c5163130bb2d80148362
---
M src/fsm.c
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/1476/2

diff --git a/src/fsm.c b/src/fsm.c
index 319c842..c0f6f3b 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -428,7 +428,7 @@
 			 const char *file, int line)
 {
 	struct osmo_fsm_inst *first_child, *last_seen_first_child;
-	struct osmo_fsm_inst *parent = fi->proc.parent;
+	struct osmo_fsm_inst *parent;
 	uint32_t parent_term_event = fi->proc.parent_term_event;
 
 	LOGPFSMSRC(fi, file, line, "Terminating (cause = %s)\n",
@@ -458,6 +458,7 @@
 	}
 
 	/* delete ourselves from the parent */
+	parent = fi->proc.parent;
 	if (parent)
 		LOGPFSMSRC(fi, file, line, "Removing from parent %s\n",
 			   osmo_fsm_inst_name(parent));
@@ -468,6 +469,8 @@
 		fi->fsm->cleanup(fi, cause);
 
 	LOGPFSMSRC(fi, file, line, "Freeing instance\n");
+	/* Fetch parent again in case it has changed. */
+	parent = fi->proc.parent;
 	osmo_fsm_inst_free(fi);
 
 	/* indicate our termination to the parent */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I999d7f29ba10281d4005c5163130bb2d80148362
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list