lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/29907 )
Change subject: fsm: add ignore_invalid_events bit-mask ......................................................................
fsm: add ignore_invalid_events bit-mask
An invalid fsm event is an event which is not valid in the current fsm state. Such invalid events will be logged and osmo_fsm_inst_dispatch() return != 0. To prevent this log message which could be misleading for the user, the code needed to add this event to the allstate_event_mask or add it independent to each state. Or as alternative create a proxy function in front of osmo_fsm_inst_dispatch() which checks the fsm state before dispatching the signal. By using ignore_invalid_events the logline can be ignored for certain events while for others the old behaviour is still preserved.
Related: SYS#6145 Change-Id: Id010ade76de83ccf428f2d18e9f85bcce1d1ea2c --- M include/osmocom/core/fsm.h M src/fsm.c 2 files changed, 13 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/29907/1
diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index 5e5b091..36e4aa4 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -81,6 +81,16 @@ const struct value_string *event_names; /*! graceful exit function, called at the beginning of termination */ void (*pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause); + /*! bit-mask of events which will be ignored if they are not valid in the current fsm state. + * + * An invalid event is an event which is neither part of the allstat_event_mask nor state->in_event_mask. + * If an invalid event is dispatched to an fsm, the fsm core will log it (error) and + * osmo_fsm_inst_dispatch() will return != 0. + * + * To silence those log lines and change the return code of osmo_fsm_inst_dispatch, add the + * event to ignore_invalid_events. + */ + uint32_t ignore_invalid_events; };
/*! a single instanceof an osmocom finite state machine */ diff --git a/src/fsm.c b/src/fsm.c index 9333cac..114b97c 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -865,6 +865,9 @@ }
if (!((1 << event) & fs->in_event_mask)) { + if ((1 << event) & fsm->ignore_invalid_events) + return 0; + LOGPFSMLSRC(fi, LOGL_ERROR, file, line, "Event %s not permitted\n", osmo_fsm_event_name(fsm, event));