fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/32552 )
Change subject: osmo-bts-trx: fix trx_ctrl_read_cb(): do not send CMDs twice ......................................................................
osmo-bts-trx: fix trx_ctrl_read_cb(): do not send CMDs twice
Sometimes osmo-bts-trx may be sending the same TRXC CMD twice. This happens when the trx_ctrl_list becomes empty in trx_ctrl_read_cb(), and a command specific response handler enqueues more commands.
The problem is that in trx_ctrl_cmd_cb() we send() the given command stright away, if the trx_ctrl_list is empty. This must be taken into account in trx_ctrl_read_cb() when calling trx_ctrl_send().
Change-Id: Ibdffa4644aa3a7d219452644d3e74b411734f1df Fixes: OS#6020 --- M src/osmo-bts-trx/trx_if.c 1 file changed, 28 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/52/32552/1
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 59603ab..51364b5 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -673,6 +673,7 @@ struct trx_ctrl_rsp rsp; int len, rc; struct trx_ctrl_msg *tcm; + bool more_cmds;
len = recv(ofd->fd, buf, sizeof(buf) - 1, 0); if (len <= 0) @@ -728,6 +729,12 @@ talloc_free(l1h->last_acked); l1h->last_acked = tcm;
+ /* Calling trx_ctrl_rx_rsp() may trigger code patch(s) queueing more CMDs. + * If this was the last CMD in the queue, a new CMD will be sent straight away, + * and calling trx_ctrl_send() below will result in sending the same CMD again. + * Avoid this by checking if we have more CMDs to send here. */ + more_cmds = !llist_empty(&l1h->trx_ctrl_list); + /* check for response code */ rc = trx_ctrl_rx_rsp(l1h, &rsp, tcm); if (rc == -EINVAL) @@ -740,7 +747,9 @@ return 0; }
- trx_ctrl_send(l1h); + /* the RSP handler might have called trx_ctrl_send() already */ + if (more_cmds) + trx_ctrl_send(l1h);
return 0;