Change in osmo-bts[master]: abis.c: Rearrange code to follow logic state order

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Sep 16 11:01:40 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/25453 )

Change subject: abis.c: Rearrange code to follow logic state order
......................................................................

abis.c: Rearrange code to follow logic state order

CONNECTING state comes first in logical order of states (as properly
seen in enum of states), however, the FSM struct definition and state
action functions are swapped. Let's put them in order.

Change-Id: I0cae561926b460dc5882390db969b7c925903e5d
---
M src/common/abis.c
1 file changed, 55 insertions(+), 55 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/src/common/abis.c b/src/common/abis.c
index fc87739..265883e 100644
--- a/src/common/abis.c
+++ b/src/common/abis.c
@@ -81,53 +81,6 @@
 	int line_ctr;
 };
 
-static void abis_link_connected(struct osmo_fsm_inst *fi, uint32_t event, void *data)
-{
-	struct abis_link_fsm_priv *priv = fi->priv;
-	struct gsm_bts *bts = priv->bts;
-	struct gsm_bts_trx *trx;
-	bool oml_rsl_was_connected = false;
-
-	OSMO_ASSERT(event == ABIS_LINK_EV_SIGN_LINK_DOWN);
-
-	/* First remove the OML signalling link */
-	if (bts->oml_link) {
-		struct timespec now;
-
-		e1inp_sign_link_destroy(bts->oml_link);
-
-		/* Log a special notice if the OML connection was dropped relatively quickly. */
-		if (bts->oml_conn_established_timestamp.tv_sec != 0 && clock_gettime(CLOCK_MONOTONIC, &now) == 0 &&
-		    bts->oml_conn_established_timestamp.tv_sec + OSMO_BTS_OML_CONN_EARLY_DISCONNECT >= now.tv_sec) {
-			LOGP(DABIS, LOGL_FATAL, "OML link was closed early within %" PRIu64 " seconds. "
-			     "If this situation persists, please check your BTS and BSC configuration files for errors. "
-			     "A common error is a mismatch between unit_id configuration parameters of BTS and BSC.\n",
-			     (uint64_t) (now.tv_sec - bts->oml_conn_established_timestamp.tv_sec));
-		}
-		bts->oml_link = NULL;
-		oml_rsl_was_connected = true;
-	}
-	memset(&bts->oml_conn_established_timestamp, 0, sizeof(bts->oml_conn_established_timestamp));
-
-	/* Then iterate over the RSL signalling links */
-	llist_for_each_entry(trx, &bts->trx_list, list) {
-		if (trx->rsl_link) {
-			e1inp_sign_link_destroy(trx->rsl_link);
-			trx->rsl_link = NULL;
-			oml_rsl_was_connected = true;
-		}
-	}
-
-	/* Note: if there was an OML or RSL connection present (the BTS was connected to a BSC). Then we will not try
-	 * to connect to an alternate BSC. Instead we will shut down the BTS process. This will ensure that all states
-	 * in the BTS (hardware and software) are reset properly. It is then up to the process management of the host
-	 * to restart osmo-bts. */
-	if (oml_rsl_was_connected)
-		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_FAILED, 0, 0);
-	else
-		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_CONNECTING, 0, 0);
-}
-
 static void abis_link_connecting_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct e1inp_line *line;
@@ -186,6 +139,53 @@
 	osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_CONNECTED, 0, 0);
 }
 
+static void abis_link_connected(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct abis_link_fsm_priv *priv = fi->priv;
+	struct gsm_bts *bts = priv->bts;
+	struct gsm_bts_trx *trx;
+	bool oml_rsl_was_connected = false;
+
+	OSMO_ASSERT(event == ABIS_LINK_EV_SIGN_LINK_DOWN);
+
+	/* First remove the OML signalling link */
+	if (bts->oml_link) {
+		struct timespec now;
+
+		e1inp_sign_link_destroy(bts->oml_link);
+
+		/* Log a special notice if the OML connection was dropped relatively quickly. */
+		if (bts->oml_conn_established_timestamp.tv_sec != 0 && clock_gettime(CLOCK_MONOTONIC, &now) == 0 &&
+		    bts->oml_conn_established_timestamp.tv_sec + OSMO_BTS_OML_CONN_EARLY_DISCONNECT >= now.tv_sec) {
+			LOGP(DABIS, LOGL_FATAL, "OML link was closed early within %" PRIu64 " seconds. "
+			     "If this situation persists, please check your BTS and BSC configuration files for errors. "
+			     "A common error is a mismatch between unit_id configuration parameters of BTS and BSC.\n",
+			     (uint64_t) (now.tv_sec - bts->oml_conn_established_timestamp.tv_sec));
+		}
+		bts->oml_link = NULL;
+		oml_rsl_was_connected = true;
+	}
+	memset(&bts->oml_conn_established_timestamp, 0, sizeof(bts->oml_conn_established_timestamp));
+
+	/* Then iterate over the RSL signalling links */
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		if (trx->rsl_link) {
+			e1inp_sign_link_destroy(trx->rsl_link);
+			trx->rsl_link = NULL;
+			oml_rsl_was_connected = true;
+		}
+	}
+
+	/* Note: if there was an OML or RSL connection present (the BTS was connected to a BSC). Then we will not try
+	 * to connect to an alternate BSC. Instead we will shut down the BTS process. This will ensure that all states
+	 * in the BTS (hardware and software) are reset properly. It is then up to the process management of the host
+	 * to restart osmo-bts. */
+	if (oml_rsl_was_connected)
+		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_FAILED, 0, 0);
+	else
+		osmo_fsm_inst_state_chg(fi, ABIS_LINK_ST_CONNECTING, 0, 0);
+}
+
 static void abis_link_failed_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
 {
 	struct abis_link_fsm_priv *priv = fi->priv;
@@ -215,6 +215,14 @@
 }
 
 static struct osmo_fsm_state abis_link_fsm_states[] = {
+	[ABIS_LINK_ST_CONNECTING] = {
+		.name = "CONNECTING",
+		.out_state_mask =
+			S(ABIS_LINK_ST_CONNECTING) |
+			S(ABIS_LINK_ST_CONNECTED) |
+			S(ABIS_LINK_ST_FAILED),
+		.onenter = abis_link_connecting_onenter,
+	},
 	[ABIS_LINK_ST_CONNECTED] = {
 		.name = "CONNECTED",
 		.in_event_mask =
@@ -224,14 +232,6 @@
 			S(ABIS_LINK_ST_FAILED),
 		.action = abis_link_connected,
 	},
-	[ABIS_LINK_ST_CONNECTING] = {
-		.name = "CONNECTING",
-		.out_state_mask =
-			S(ABIS_LINK_ST_CONNECTING) |
-			S(ABIS_LINK_ST_CONNECTED) |
-			S(ABIS_LINK_ST_FAILED),
-		.onenter = abis_link_connecting_onenter,
-	},
 	[ABIS_LINK_ST_FAILED] = {
 		.name = "FAILED",
 		.onenter = abis_link_failed_onenter,

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/25453
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I0cae561926b460dc5882390db969b7c925903e5d
Gerrit-Change-Number: 25453
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210916/aa139e1d/attachment.htm>


More information about the gerrit-log mailing list