Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1494180iol; Fri, 10 Jun 2022 08:35:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZLXQtHdgYr0hRG/HQH0nlxOcDT18IitF9ELUBke54uFS/q3tB8ebQl18LC+SGzRc0F61V X-Received: by 2002:aa7:ca59:0:b0:42d:c34e:5832 with SMTP id j25-20020aa7ca59000000b0042dc34e5832mr50963126edt.75.1654875356342; Fri, 10 Jun 2022 08:35:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654875356; cv=pass; d=google.com; s=arc-20160816; b=NdQTAK1ZK1ziN91LjY6lEjKoMtWkXr5Z8deVSSYY/Hsu+ngJqlXZp1ONvFxkZ/VOpC 2mtewTT+d9WlATeFnXukd5JwplSQ717GNKhY/eg03RRotv85FtCv2hewUzlYzanfvIOU TNGUpSRnnG4EA7aGJnz05HJ4cUFMuugaEdfPcWzFAE7pWXKbiuRJiaa99dVobuGP9/mD PyHppWOVRKrwz5o5OD9RY2ntOae03AJlG7SWtSzMgqrMTrPA9JG63FYA37PJtyll08PH XE5TcHVLHuwuLpDhJHsCxuoM5bZvFcjsRyvJNqYIuRDMcGifHqzBQRzPeO8BeUFj+2on uE8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4kS1pi947nXQQFN2ndEcRfeWV/JS6OnGl2KBu5Hg+is=; b=rk0nNCcFCM4AG5+IXCca7/GaVqOngc0uFIxe16d6QQ/cGPgGOKKyhY7ceNaOZOOGlz nzbfiiGp/kIj6pwD+rNeUC9a22tkJTzbEN0i5lltthmV9mE3XLwsUm7upvp12vS+UK3b U7hoCOQGBUMeblq1gvdC+TJObM4smSpeasKuiaV4sGC9hsXGC2Ji9hBor1cpwyYyXq+N LiNI5BpfI2kZrA45FxYZpoJaEf7WWAs8y8PjjhsQA4w1Kdr+DB1v8th4uNP9YuMXxNqE AwzlOZ9uiTCHEBH+uc3mvz8ULk6K4wKRnqbxFarTkVPbJQun0sn+Ud4ptpZa7RUbamSD Qp6A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@dptechnics.com header.s=zoho header.b=IfpU0AU3; arc=pass (i=1 spf=pass spfdomain=dptechnics.com dkim=pass dkdomain=dptechnics.com dmarc=pass fromdomain=dptechnics.com>); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a05640205ca00b0042f94821fbfsi9486607edx.176.2022.06.10.08.34.47; Fri, 10 Jun 2022 08:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dptechnics.com header.s=zoho header.b=IfpU0AU3; arc=pass (i=1 spf=pass spfdomain=dptechnics.com dkim=pass dkdomain=dptechnics.com dmarc=pass fromdomain=dptechnics.com>); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239010AbiFJPaK (ORCPT + 99 others); Fri, 10 Jun 2022 11:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237844AbiFJPaJ (ORCPT ); Fri, 10 Jun 2022 11:30:09 -0400 Received: from sender4-op-o13.zoho.com (sender4-op-o13.zoho.com [136.143.188.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3010DFF9 for ; Fri, 10 Jun 2022 08:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654875007; cv=none; d=zohomail.com; s=zohoarc; b=OKHls988t4Mvr4IEWqAmjBuJhL5WKo9wXlEZrhdPxbUQjL/S0Spq6772GcG11JOvhc4rp6BPzOUqdfDFGPWericsqZ8dkKCGeKk0AAyZTp0RmaFn+kO2TAOU6d0VHvFlfuX3RRPFYM8ufFJ6rxEIbEWqj3Ec19T6vIgZUw8ymKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654875007; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4kS1pi947nXQQFN2ndEcRfeWV/JS6OnGl2KBu5Hg+is=; b=YsgQjBe7hJL++rhSugFqz6qPPfE6u8kKin8eQZDlTUvm/EeEHqJit9dkNHvZDCfFTvB8fnq263rzbsFWXgJZuFk4RdLR87grxBhIV93kIaY9cPGyAvOUL/JhBRvH0w3hgA0XbT4z1BLS2MLkv9Noz6SGx/S7RdNt+0RgR0mxnyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=dptechnics.com; spf=pass smtp.mailfrom=jonas@dptechnics.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1654875007; s=zoho; d=dptechnics.com; i=jonas@dptechnics.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=4kS1pi947nXQQFN2ndEcRfeWV/JS6OnGl2KBu5Hg+is=; b=IfpU0AU3EJ70cFUNCXMUc3ua1Zpb1wq9jzLERszzLO7wSyvmYmhbG9WlUr1x9wmM 2uFzNuQEPCxSuGKSQPsAGS7R0hS/STBMbyIrwsp5ZJEzjiwe7nU6AyiycuZi1kT8+vU OpMbsJLQg62D5Y22vRJhmtN7t/Dl7mWY5LW7C6AU= Received: from lilith.dptechnics.local (178-116-74-88.access.telenet.be [178.116.74.88]) by mx.zohomail.com with SMTPS id 1654875004909492.82336920813896; Fri, 10 Jun 2022 08:30:04 -0700 (PDT) From: Jonas Maes To: linux-bluetooth@vger.kernel.org Cc: Jonas Maes Subject: [PATCH BlueZ 1/1] Fix bug where bluetooth-meshd stops sending Date: Fri, 10 Jun 2022 17:29:02 +0200 Message-Id: <20220610152902.21677-2-jonas@dptechnics.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220610152902.21677-1-jonas@dptechnics.com> References: <20220610152902.21677-1-jonas@dptechnics.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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. UPDATE: long line split in 2 lines now --- mesh/mesh-io-generic.c | 19 ++++++++----------- 1 file 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); -- 2.35.1