diff options
author | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-14 19:46:33 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-02-27 22:27:52 +0100 |
commit | 83d6c2f0e438ec4129bddb9a54ce9dd2777c0748 (patch) | |
tree | 69656b0968501e13626b848c48ca81f708bb249e /src/osmobts_sock.cpp | |
parent | 8bba6a29e555fb301c040289912c9d711f8af9bf (diff) |
Make osmo-pcu wait for BTS to become available at start-up time.
After the PCU socket becomes available, the BTS might send an
INFO_IND message with the 'ACTIVE' flag cleared. If this happens,
do not exit immediately, but keep retrying until an INFO_IND
message with the 'ACTIVE' flag arrives.
Note that this change only affects behaviour at process start-up time.
If the BTS switches from active to inactive state then osmo-pcu will
still exit. If this behaviour should be changed as well it could be
done in a follow-up patch.
Tested against osom-bsc + osmo-bts-virtual.
Change-Id: Ic42a5601a43b81d260721fef5d9fa52447f9d309
Related: OS#2689
Diffstat (limited to 'src/osmobts_sock.cpp')
-rw-r--r-- | src/osmobts_sock.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp index 577d41eb..9e4000a0 100644 --- a/src/osmobts_sock.cpp +++ b/src/osmobts_sock.cpp @@ -55,7 +55,23 @@ struct pcu_sock_state { struct llist_head upqueue; /* queue for sending messages */ } *pcu_sock_state = NULL; -static void pcu_sock_timeout(void *_priv); +static void pcu_sock_timeout(void *_priv) +{ + pcu_l1if_open(); +} + +static void pcu_tx_txt_retry(void *_priv) +{ + struct gprs_rlcmac_bts *bts = bts_main_data(); + struct pcu_sock_state *state = pcu_sock_state; + + if (bts->active) + return; + + LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION); + pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION); + osmo_timer_schedule(&state->timer, 5, 0); +} int pcu_sock_send(struct msgb *msg) { @@ -268,7 +284,7 @@ int pcu_l1if_open(void) pcu_sock_state = state; close(bfd->fd); bfd->fd = -1; - state->timer.cb = pcu_sock_timeout; + osmo_timer_setup(&state->timer, pcu_sock_timeout, NULL); osmo_timer_schedule(&state->timer, 5, 0); return 0; } @@ -293,6 +309,10 @@ int pcu_l1if_open(void) LOGP(DL1IF, LOGL_INFO, "Sending version %s to BTS.\n", PACKAGE_VERSION); pcu_tx_txt_ind(PCU_VERSION, "%s", PACKAGE_VERSION); + /* Schedule a timer so we keep trying until the BTS becomes active. */ + osmo_timer_setup(&state->timer, pcu_tx_txt_retry, NULL); + osmo_timer_schedule(&state->timer, 5, 0); + return 0; } @@ -312,8 +332,3 @@ void pcu_l1if_close(void) talloc_free(state); pcu_sock_state = NULL; } - -static void pcu_sock_timeout(void *_priv) -{ - pcu_l1if_open(); -} |