summaryrefslogtreecommitdiff
path: root/mesh
diff options
context:
space:
mode:
authorJonas Maes <jonas@dptechnics.com>2022-06-10 17:29:02 +0200
committerBrian Gix <brian.gix@intel.com>2022-06-21 13:18:16 -0700
commit71560e12863ff1b133e421ef7dd25d20c8d83acc (patch)
treecda99b492c8501c2ea049fc66c68e28da3bda543 /mesh
parent949898cc5e7f0657dff91f799718e54dc4cde723 (diff)
downloadbluez-71560e12863ff1b133e421ef7dd25d20c8d83acc.tar.gz
mesh: Fix bug where bluetooth-meshd stops sending
When there is a backlog of mesh packets to be sent, the packet sender Fix bug where bluetooth-meshd stops sending When there is a backlog of mesh packets to be sent, the packet sender incorrectly infers that the tx worker thread is already running and therefore needn't be invoked. As a result, the mesh daemon will sometimes stop broadcasting while there are still packets in the queue. It will not resume broadcasting. This patch will invoke the tx worker thread correctly in that case. The logic to send packets at least twice when the transmitter is idle was slightly modified accordingly, and should behave the same way as before.
Diffstat (limited to 'mesh')
-rw-r--r--mesh/mesh-io-generic.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
index 50a2a6a86..2d7ef261e 100644
--- a/mesh/mesh-io-generic.c
+++ b/mesh/mesh-io-generic.c
@@ -725,7 +725,6 @@ static bool send_tx(struct mesh_io *io, struct mesh_io_send_info *info,
{
struct mesh_io_private *pvt = io->pvt;
struct tx_pkt *tx;
- bool sending = false;
if (!info || !data || !len || len > sizeof(tx->pkt))
return false;
@@ -739,23 +738,21 @@ static bool send_tx(struct mesh_io *io, struct mesh_io_send_info *info,
if (info->type == MESH_IO_TIMING_TYPE_POLL_RSP)
l_queue_push_head(pvt->tx_pkts, tx);
else {
- if (pvt->tx)
- sending = true;
- else
- sending = !l_queue_isempty(pvt->tx_pkts);
-
- l_queue_push_tail(pvt->tx_pkts, tx);
-
/*
* If transmitter is idle, send packets at least twice to
* guard against in-line cancelation of HCI command chain.
*/
- if (info->type == MESH_IO_TIMING_TYPE_GENERAL && !sending &&
- tx->info.u.gen.cnt == 1)
+ if (info->type == MESH_IO_TIMING_TYPE_GENERAL &&
+ !pvt->tx &&
+ l_queue_isempty(pvt->tx_pkts) &&
+ tx->info.u.gen.cnt == 1)
tx->info.u.gen.cnt++;
+
+ l_queue_push_tail(pvt->tx_pkts, tx);
}
- if (!sending) {
+ /* If not already sending, schedule the tx worker */
+ if (!pvt->tx) {
l_timeout_remove(pvt->tx_timeout);
pvt->tx_timeout = NULL;
l_idle_oneshot(tx_worker, pvt, NULL);