diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-09-29 19:51:29 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-09-30 13:15:24 +0200 |
commit | 1c3431db95950ea47938524921ce9ae6a7d2128b (patch) | |
tree | 2b868079018c2e92032894f0d9651cbaf02098a3 | |
parent | d17beeacde000819c6481982da92fceed49eceb9 (diff) |
Delay abis reconnect while bts is shutting down
Avoid re-connecting to a new BSC while BTS is in shutting down. All the
FSMs are complex enough to even try to re-start when stopping has not
yet finished...
Change-Id: I1727828a16f4ec8043b00cc6b2e02a4c35f71377
-rw-r--r-- | include/osmo-bts/bts_shutdown_fsm.h | 3 | ||||
-rw-r--r-- | src/common/abis.c | 7 | ||||
-rw-r--r-- | src/common/bts_shutdown_fsm.c | 8 |
3 files changed, 17 insertions, 1 deletions
diff --git a/include/osmo-bts/bts_shutdown_fsm.h b/include/osmo-bts/bts_shutdown_fsm.h index 1e74ac6b..76ac6ca6 100644 --- a/include/osmo-bts/bts_shutdown_fsm.h +++ b/include/osmo-bts/bts_shutdown_fsm.h @@ -39,3 +39,6 @@ enum bts_shutdown_fsm_events { }; extern struct osmo_fsm bts_shutdown_fsm; + +struct gsm_bts; +bool bts_shutdown_in_progress(const struct gsm_bts *bts); diff --git a/src/common/abis.c b/src/common/abis.c index 11111fa3..f1fb10c6 100644 --- a/src/common/abis.c +++ b/src/common/abis.c @@ -53,6 +53,7 @@ #include <osmo-bts/abis_osmo.h> #include <osmo-bts/bts_model.h> #include <osmo-bts/bts_trx.h> +#include <osmo-bts/bts_shutdown_fsm.h> static struct gsm_bts *g_bts; @@ -137,6 +138,12 @@ static void abis_link_connecting_onenter(struct osmo_fsm_inst *fi, uint32_t prev struct abis_link_fsm_priv *priv = fi->priv; struct gsm_bts *bts = priv->bts; + if (bts_shutdown_in_progress(bts)) { + LOGPFSML(fi, LOGL_NOTICE, "BTS is shutting down, delaying A-bis connection establishment to BSC\n"); + osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_WAIT_RECONNECT, OML_RETRY_TIMER, 0); + return; + } + if (pick_next_bsc(fi) < 0) { LOGPFSML(fi, LOGL_FATAL, "No BSC available, A-bis connection establishment failed\n"); osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_FAILED, 0, 0); diff --git a/src/common/bts_shutdown_fsm.c b/src/common/bts_shutdown_fsm.c index 85d2d837..a663f5bf 100644 --- a/src/common/bts_shutdown_fsm.c +++ b/src/common/bts_shutdown_fsm.c @@ -237,10 +237,16 @@ static __attribute__((constructor)) void bts_shutdown_fsm_init(void) OSMO_ASSERT(osmo_fsm_register(&bts_shutdown_fsm) == 0); } +bool bts_shutdown_in_progress(const struct gsm_bts *bts) +{ + const struct osmo_fsm_inst *fi = bts->shutdown_fi; + return fi->state != BTS_SHUTDOWN_ST_NONE; +} + 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) { + if (bts_shutdown_in_progress(bts)) { LOGPFSML(fi, LOGL_NOTICE, "BTS is already being shutdown.\n"); if (exit_proc) bts->shutdown_fi_exit_proc = true; |