mirror of https://gerrit.osmocom.org/libosmocore
fsm: add ignore_invalid_event_mask 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
This commit is contained in:
parent
19bd12e919
commit
f7ed2f53ba
|
@ -81,6 +81,16 @@ struct osmo_fsm {
|
|||
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_event_mask.
|
||||
*/
|
||||
uint32_t ignore_invalid_event_mask;
|
||||
};
|
||||
|
||||
/*! a single instanceof an osmocom finite state machine */
|
||||
|
|
|
@ -865,6 +865,9 @@ int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data
|
|||
}
|
||||
|
||||
if (!((1 << event) & fs->in_event_mask)) {
|
||||
if ((1 << event) & fsm->ignore_invalid_event_mask)
|
||||
return 0;
|
||||
|
||||
LOGPFSMLSRC(fi, LOGL_ERROR, file, line,
|
||||
"Event %s not permitted\n",
|
||||
osmo_fsm_event_name(fsm, event));
|
||||
|
|
Loading…
Reference in New Issue