From f627c0f0afb280d30aa00da395560db963aba462 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 18 Jun 2016 10:36:25 +0200 Subject: fsm: Introduce default time-out handling If a FSM doesn't specify any timer_cb, simply terminate the FSM by default on time-out. This is a reasonable default for most cases, and avoids copy+pasting a one-line timer_cb function in every FSM. Also, even if there is a timer_cb, let it have a return value to decide if the core should terminate after return from timer_cb or not. Change-Id: I0461a9593bfb729c82b7d1d1cf9f30b1079d0212 --- include/osmocom/core/fsm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/osmocom/core') diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index 401ee04a..ce0db15a 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -26,6 +26,8 @@ enum osmo_fsm_term_cause { OSMO_FSM_TERM_REGULAR, /*! \brief erroneous termination of process */ OSMO_FSM_TERM_ERROR, + /*! \brief termination due to time-out */ + OSMO_FSM_TERM_TIMEOUT, }; /*! \brief description of a rule in the FSM */ @@ -63,7 +65,7 @@ struct osmo_fsm { /*! \breif clean-up function, called during termination */ void (*cleanup)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause); /*! \brief timer call-back for states with time-out */ - void (*timer_cb)(struct osmo_fsm_inst *fi); + int (*timer_cb)(struct osmo_fsm_inst *fi); /*! \brief logging sub-system for this FSM */ int log_subsys; /*! \brief human-readable names of events */ -- cgit v1.2.3