aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-09-21 17:09:17 +0200
committerpespin <pespin@sysmocom.de>2021-09-23 12:07:29 +0000
commit37f63f12f766beb1e766075796fec4ae3b912e74 (patch)
tree5ea81d77f12b901c3e879d7dc45e6671f7100df8
parent4ddc37ce7140e5ce6ca6cce5aeeefedc0d395d22 (diff)
bts_shutdown_fsm: Allow configuring FSM to shutdown without exiting process
This feature is not yet used by any bts_shutdown_fsm caller, but will be used in the future when Abis link goes down. Change-Id: I5dc282fdbcf862067be326e72b6183dd544222ae
-rw-r--r--include/osmo-bts/bts.h2
-rw-r--r--src/common/bts_shutdown_fsm.c23
2 files changed, 20 insertions, 5 deletions
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index d3cb6bff..a6014239 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -368,6 +368,7 @@ struct gsm_bts {
} gsmtap;
struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */
+ bool shutdown_fi_exit_proc; /* exit process when shutdown_fsm is finished? */
struct osmo_fsm_inst *abis_link_fi; /* FSM instance to manage abis connection during process startup and link failure */
struct osmo_tdef *T_defs; /* Timer defines */
@@ -390,6 +391,7 @@ struct gsm_bts *gsm_bts_num(const struct gsm_network *net, int num);
int bts_init(struct gsm_bts *bts);
void bts_shutdown(struct gsm_bts *bts, const char *reason);
+void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc);
int bts_link_estab(struct gsm_bts *bts);
diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c
index c16b76ad..85d2d837 100644
--- a/src/common/bts_shutdown_fsm.c
+++ b/src/common/bts_shutdown_fsm.c
@@ -156,8 +156,11 @@ static void st_exit_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_SHUTDOWN_FINISH, NULL);
- LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfuly, exiting process\n");
- exit(0);
+ if (bts->shutdown_fi_exit_proc) {
+ LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfully, exiting process\n");
+ exit(0);
+ }
+ bts_shutdown_fsm_state_chg(fi, BTS_SHUTDOWN_ST_NONE);
}
static struct osmo_fsm_state bts_shutdown_fsm_states[] = {
@@ -190,6 +193,8 @@ static struct osmo_fsm_state bts_shutdown_fsm_states[] = {
},
[BTS_SHUTDOWN_ST_EXIT] = {
.name = "EXIT",
+ .out_state_mask =
+ X(BTS_SHUTDOWN_ST_NONE),
.onenter = st_exit_on_enter,
}
};
@@ -232,18 +237,26 @@ static __attribute__((constructor)) void bts_shutdown_fsm_init(void)
OSMO_ASSERT(osmo_fsm_register(&bts_shutdown_fsm) == 0);
}
-void bts_shutdown(struct gsm_bts *bts, const char *reason)
+void bts_shutdown_ext(struct gsm_bts *bts, const char *reason, bool exit_proc)
{
struct osmo_fsm_inst *fi = bts->shutdown_fi;
if (fi->state != BTS_SHUTDOWN_ST_NONE) {
LOGPFSML(fi, LOGL_NOTICE, "BTS is already being shutdown.\n");
+ if (exit_proc)
+ bts->shutdown_fi_exit_proc = true;
return;
}
-
- LOGPFSML(fi, LOGL_NOTICE, "Shutting down BTS, reason: %s\n", reason);
+ bts->shutdown_fi_exit_proc = exit_proc;
+ LOGPFSML(fi, LOGL_NOTICE, "Shutting down BTS, exit %u, reason: %s\n",
+ exit_proc, reason);
osmo_fsm_inst_dispatch(fi, BTS_SHUTDOWN_EV_START, NULL);
}
+void bts_shutdown(struct gsm_bts *bts, const char *reason)
+{
+ bts_shutdown_ext(bts, reason, true);
+}
+
void bts_model_trx_close_cb(struct gsm_bts_trx *trx, int rc)
{
struct osmo_fsm_inst *fi = trx->bts->shutdown_fi;