From 4b4c2ec4b324b94b0a4f6b4c36a68bfc60bfce3d Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 8 Dec 2017 18:34:52 +0100 Subject: bts-trx: Avoid enqueueing consecutive duplicate messages to TRX While debugging other protocol/timing issues between osmobts-trx and osmo-trx, I found that sometimes two consecutives "POWER OFF" commands are enqueued and sent to osmo-trx. There's no point in doing so, as the write queue already maintains state and retries the command until a RSP is received, then goes for the next one. With this change we hence improve timing response as we don't need to wait for the second command to be processed, and on top we get cleaner logs and simplified states which are easier to debug. Change-Id: Ib6a5e7bfac8bc5e1b372da6a1f801c07a3d5ebb7 --- src/osmo-bts-trx/trx_if.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/osmo-bts-trx/trx_if.c') diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 1ac21d59..57fd953a 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -214,8 +214,13 @@ static int trx_ctrl_cmd(struct trx_l1h *l1h, int critical, const char *cmd, tcm->cmd[sizeof(tcm->cmd)-1] = '\0'; tcm->cmd_len = strlen(cmd); tcm->critical = critical; - llist_add_tail(&tcm->list, &l1h->trx_ctrl_list); - LOGP(DTRX, LOGL_INFO, "Enqueuing TRX control command '%s'\n", tcm->cmd); + + /* Avoid adding consecutive duplicate messages, eg: two consecutive POWEROFF */ + if (!pending || + strcmp(tcm->cmd, llist_entry(l1h->trx_ctrl_list.prev, struct trx_ctrl_msg, list)->cmd)) { + LOGP(DTRX, LOGL_INFO, "Enqueuing TRX control command '%s'\n", tcm->cmd); + llist_add_tail(&tcm->list, &l1h->trx_ctrl_list); + } /* send message, if we didn't already have pending messages */ if (!pending) -- cgit v1.2.3