From 3b414a4adc8687af1a32f36fc1553bc65fb6b348 Mon Sep 17 00:00:00 2001
From: Neels Hofmeyr <neels@hofmeyr.de>
Date: Mon, 8 Apr 2019 00:33:53 +0200
Subject: fsm: add flag to ensure osmo_fsm_inst_term() happens only once

To prevent re-entering osmo_fsm_inst_term() twice for the same osmo_fsm_inst,
add flag osmo_fsm_inst.proc.terminating. osmo_fsm_inst_term() sets this to
true, or exits if it already is true.

Update fsm_dealloc_test.err for illustration. It is not relevant for unit
testing yet, just showing the difference.

Change-Id: I0c02d76a86f90c49e0eae2f85db64704c96a7674
---
 include/osmocom/core/fsm.h | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'include/osmocom')

diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index c40d7f3c..07bcd126 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -114,6 +114,8 @@ struct osmo_fsm_inst {
 		struct llist_head children;
 		/*! \ref llist_head linked to parent->proc.children */
 		struct llist_head child;
+		/*! Indicator whether osmo_fsm_inst_term() was already invoked on this instance. */
+		bool terminating;
 	} proc;
 };
 
-- 
cgit v1.2.3