From 3b414a4adc8687af1a32f36fc1553bc65fb6b348 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr 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 --- src/fsm.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/fsm.c') diff --git a/src/fsm.c b/src/fsm.c index d86ff4b5..d18406af 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -710,6 +710,12 @@ void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi, struct osmo_fsm_inst *parent; uint32_t parent_term_event = fi->proc.parent_term_event; + if (fi->proc.terminating) { + LOGPFSMSRC(fi, file, line, "Ignoring trigger to terminate: already terminating\n"); + return; + } + fi->proc.terminating = true; + LOGPFSMSRC(fi, file, line, "Terminating (cause = %s)\n", osmo_fsm_term_cause_name(cause)); -- cgit v1.2.3