Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1510698pxf; Fri, 12 Mar 2021 11:12:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwg497uUV0t6B6EYsRa2I4fqx1X5J76xvEEewcdwlU3RV5ulgTBmHM76GrV9ef0l933crA X-Received: by 2002:a17:907:7355:: with SMTP id dq21mr9975425ejc.159.1615576358081; Fri, 12 Mar 2021 11:12:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615576358; cv=none; d=google.com; s=arc-20160816; b=xSL2+ZGQ08rr0kwzw88i+F6HYrVZ/2PKwXNLpbUFWKDBWZF4IXVpQAt9OTx1+A1pPZ W9F7DjIydI+SjkWaSA9RCd1IdCbemZeK0aZud1MQ1TbPtYUY70Gbgou6daXc6rvRc076 qOTSXYcPrPlpYyIjkCi1bS2/c7mJh9n843oVEDWSqMFQBB7KfUbJMJRbx5P9aPCAjPb0 ZF+iqoP4YhGqJ/VrCKcfYKrKZ56VqYy7/9qmlRPgEIzi78x7nQsH66keeui+uFjS1Wcq sSrafM+6OHIV4sUq3WdivyIYShm7PPufFbdnZ3Kvb7UAuwdHvc3QnupUBg/XbEEhYx9D tQ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=0QPXnh9lS1FKwo5rzvdC+Xwnx/5kY7kJmIq3nLkDsWk=; b=RMVrHhBwcKHUf6GsHh34X5NQMopsmxW0rzD1NyVB1cq9c5igXHmrF3r4iWAdCm/Bxk xwTOHg8EUvFq2j4uHWgpjYd4FQ2VkEFW03sEQUATnEQvWspvOD5FFugI9TCw56EGu4Hl veO8LguntFteO33eSnK5B94z2ezhwkTxFzSzBzQgvMVfji0rc8lRfdXHi+6tYTp6G5N5 TxZHmtS6y4ozc67xvyUQklvqgM3vXmgGVLJUbHQJHkiGarl42b2DIf6xM/bdqvtLTfY3 WHDton98SxXnQFZMmUA2qGA2mZAluW521m9IqvpgP8I9V8cQVAi7FHAbHJ9CPG1ehOEh KKNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf1si4990373ejc.433.2021.03.12.11.11.59; Fri, 12 Mar 2021 11:12:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234223AbhCLTJo (ORCPT + 99 others); Fri, 12 Mar 2021 14:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234218AbhCLTJj (ORCPT ); Fri, 12 Mar 2021 14:09:39 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA470C061574 for ; Fri, 12 Mar 2021 11:09:38 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: fdanis) with ESMTPSA id 425001F46E67 Subject: Re: [PATCH Bluez v2] adapter: Fix discovery trigger for 0 second delay To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" References: <20210312165017.31829-1-frederic.danis@collabora.com> From: =?UTF-8?Q?Fr=c3=a9d=c3=a9ric_Danis?= Message-ID: <49e20ff2-795c-12e9-db79-697b12725f12@collabora.com> Date: Fri, 12 Mar 2021 20:09:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, On 12/03/2021 19:28, Luiz Augusto von Dentz wrote: > Hi Frédéric, > > On Fri, Mar 12, 2021 at 8:53 AM Frédéric Danis > wrote: >> When calling `StartDiscovery` the effective start can take around 10 ms or >> up to 700 ms. >> g_timeout_add_seconds() call doesn't ensure the time for the first call of >> the timer if the delay is less or equal to 1 second. > Interesting, I always thought that 0 would be handle just as idle and > not round up to the next timeout. > >> --- >> v2: Fix issue founs by CI >> >> src/adapter.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/src/adapter.c b/src/adapter.c >> index cc0849f99..3078ce1a8 100644 >> --- a/src/adapter.c >> +++ b/src/adapter.c >> @@ -1797,6 +1797,13 @@ static void trigger_start_discovery(struct btd_adapter *adapter, guint delay) >> if (!btd_adapter_get_powered(adapter)) >> return; >> >> + if (!delay) { >> + adapter->discovery_idle_timeout = g_idle_add( >> + start_discovery_timeout, >> + adapter); >> + return; >> + } >> + >> adapter->discovery_idle_timeout = g_timeout_add_seconds(delay, >> start_discovery_timeout, adapter); > Maybe we should have a wrapper function for g_timeout_add_seconds > since I suspect there might be other instances of > g_timeout_add_seconds with 0 delay. Ok Is adding a timeout_add_seconds() function to src/shared/timeout.h the right place? Fred