Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3097056pxk; Tue, 15 Sep 2020 09:58:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHzGASdQxZlXdfngZ6+e65N4J7lSxHmSQUOur1+CUGRFfmBSgmlp4HDMcObm3jWGwwgpi1 X-Received: by 2002:a17:906:1f43:: with SMTP id d3mr20042483ejk.295.1600189107351; Tue, 15 Sep 2020 09:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600189107; cv=none; d=google.com; s=arc-20160816; b=IipGKBG58PS9n6jcSWTq9axv9DSMlOR9tW+wkj8DZNFwhLKthDsnCrduKyCNS1uq0q CJhtMOm1FNAsfPZRvwR9CwW/faNID+3s5ZpZ19VZS+kdYVZQxwzm8/4VV49WPSLw2ED4 n6c4sBlZ115LtD8H1rGHirJNQXXsx9oXvLphP7ybFdZKR4UWYOol/13goB1i/YTcj/5M ZK3sCAEQbLSPvEMIJPcSpocXi7EfzoVDm5f9JeyU9/tWdu2ed6slwQkKIG8PTCfVPUx9 JnS87NJfjtNNsQWmsVeIYOtb02SVPu8h+Cdo2Xcz89T9J73YU4a0h9gObGVJQ+EweVUA FiWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vZJ5c1oNq+PSxzLvAz6o8y4iFvnbqXrW0+p9q2WgnWU=; b=PaqEliCi6elC8SR7o7LSVYCDgp6T78qe1s7DZcHiQmdV7ZiWIDn7Jflye55cLcjKzx BFw8I/I4A09r9SgHj7OjDhZfxqGunkOcfAWzUfF3CLHVoLTel8T8+WDL0JexU9MO+1bV 5MwlmqnYgJFS30woZaDtT/m3DBEJ70cLu6MIzDu+4VHwfJsuaWdK5UUBJ10IBsoZgZKn ClaeABhzaDn2VtmAbbbmc6YJ7uTBz90lpDe/Kkgfo1VTEAva4xy8TKfnnvd4GzKinQmD L6nd/XE5ryGBXa6KszYsjmrAv+ejHxuEDwXnK/msfCl4OQhBBobgBGWZwTrkXzVWvcvV m2/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CUfXU1Ik; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay11si9647255edb.517.2020.09.15.09.57.44; Tue, 15 Sep 2020 09:58:27 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CUfXU1Ik; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbgIOQ4x (ORCPT + 99 others); Tue, 15 Sep 2020 12:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbgIOQwa (ORCPT ); Tue, 15 Sep 2020 12:52:30 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22778C061788 for ; Tue, 15 Sep 2020 09:51:24 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id c10so3848573otm.13 for ; Tue, 15 Sep 2020 09:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vZJ5c1oNq+PSxzLvAz6o8y4iFvnbqXrW0+p9q2WgnWU=; b=CUfXU1IkphycK6bsRwjflyuwE1/Em2IzPeqsbuVF34bcaPNQLzbGwk1mMZposk5ytP cBA1etA0WnkgscwRRK9xXLU+xokgCoukPb8T4/VF1Lo4e7F+7bAiTHh1Aje+uv3RRPpT qBEZ60QP2t8zg3JT92AFTllXyhW1FoKu6JmtS57M8OAv8aHQ7nf0ZjilA5Lc+DnZtKBq BSjDC2qrvPzURPONKJxdBgjGh21bTdmaAI6DosdUmCtIg/XpM7CRuOGgiTnHVxcgOyju vCwRSQJWU3tov7sYF6g6cNfsYB3unEEHyDJxMfS69xwS7wWwaQDBkZ2856ezU/PYujoi qJ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vZJ5c1oNq+PSxzLvAz6o8y4iFvnbqXrW0+p9q2WgnWU=; b=n+OCETZ+pU0ChlSJHVBxkd7K7hDjJ80GX2t9dTPfzBoymHNUSAUdQDD8GQBMKfFZmF eGDOsSsOZI0mOYc7FOgIwvkHfIH+tgphnFBIWndwjSwPkJXoq5/h7RwuGYsuxBKOFPzh ICorghw8EQwbRTdoFDooHaLBxatyV5iTnl1zbSUtnKILW1AwOKbfaIjpHaamJFqmFXU/ 9GAVH2FzXd+s94hjlD1/TLz0X+IHkKwvZZeflHTJSlgieudTYtli++ar9nD9aeqolglb dViFix3m2CxFGMBGlydWTGowVoRFqnHDP4li+h/QkWTF0sVl+EjCoDcqSf0dT11kpLe3 vWQg== X-Gm-Message-State: AOAM532l+MLuDU4ALHqU5LFiOHpvjquE1caGTG5alBNqD0v5jTnUImB6 PeQxoB5bDyA2rRDfuKowXn40Wj1M0qcdCBrCil4= X-Received: by 2002:a9d:5a8:: with SMTP id 37mr5439144otd.362.1600188683403; Tue, 15 Sep 2020 09:51:23 -0700 (PDT) MIME-Version: 1.0 References: <20200915110347.Bluez.v3.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> In-Reply-To: <20200915110347.Bluez.v3.1.If16fd16b4a629ec4d4093a974256225a95b58044@changeid> From: Luiz Augusto von Dentz Date: Tue, 15 Sep 2020 09:51:12 -0700 Message-ID: Subject: Re: [Bluez PATCH v3] device: don't wait for timeout if RemoveDevice is called To: Archie Pusaka Cc: linux-bluetooth , CrosBT Upstreaming , Archie Pusaka , Daniel Winkler Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Archie, On Mon, Sep 14, 2020 at 8:04 PM Archie Pusaka wrote: > > From: Archie Pusaka > > RemoveDevice on adapter interface used to remove a device, even when > the device is connected. However, since the introduction of the new > 30 seconds timeout when setting a device as temporary, RemoveDevice > doesn't immediately remove a connected device, but only disconnects > it and waits for the timer to expire before effectively removes it. > > This patch removes the device as soon as it gets disconnected, > provided the disconnection is triggered by a call to RemoveDevice. > The regular timeout still applies for other cases. > > Tested manually by calling RemoveDevice on a connected device, > and with ChromeOS autotest setup. > > Reviewed-by: Daniel Winkler > --- > > Changes in v3: > * Rebasing again > > Changes in v2: > * Rebasing to HEAD > > src/adapter.c | 2 -- > src/adapter.h | 2 ++ > src/device.c | 11 +++++++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/src/adapter.c b/src/adapter.c > index df628a7fd..4e27bd74b 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -80,8 +80,6 @@ > #include "adv_monitor.h" > #include "eir.h" > > -#define ADAPTER_INTERFACE "org.bluez.Adapter1" > - > #define MODE_OFF 0x00 > #define MODE_CONNECTABLE 0x01 > #define MODE_DISCOVERABLE 0x02 > diff --git a/src/adapter.h b/src/adapter.h > index c70a7b0da..2f1e4b737 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -29,6 +29,8 @@ > #include > #include > > +#define ADAPTER_INTERFACE "org.bluez.Adapter1" > + > #define MAX_NAME_LENGTH 248 > > /* Invalid SSP passkey value used to indicate negative replies */ > diff --git a/src/device.c b/src/device.c > index 8f73ce4d3..3e7784034 100644 > --- a/src/device.c > +++ b/src/device.c > @@ -3007,6 +3007,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > { > struct bearer_state *state = get_state(device, bdaddr_type); > DBusMessage *reply; > + bool remove_device = false; > > if (!state->connected) > return; > @@ -3036,6 +3037,10 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > while (device->disconnects) { > DBusMessage *msg = device->disconnects->data; > > + if (dbus_message_is_method_call(msg, ADAPTER_INTERFACE, > + "RemoveDevice")) > + remove_device = true; > + > g_dbus_send_reply(dbus_conn, msg, DBUS_TYPE_INVALID); > device->disconnects = g_slist_remove(device->disconnects, msg); > dbus_message_unref(msg); > @@ -3061,6 +3066,9 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) > > g_dbus_emit_property_changed(dbus_conn, device->path, > DEVICE_INTERFACE, "Connected"); > + > + if (remove_device) > + btd_adapter_remove_device(device->adapter, device); > } > > guint device_add_disconnect_watch(struct btd_device *device, > @@ -4482,6 +4490,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored) > disconnect_all(device); > } > > + if (device->temporary_timer > 0) > + g_source_remove(device->temporary_timer); > + > if (device->store_id > 0) { > g_source_remove(device->store_id); > device->store_id = 0; > -- > 2.28.0.618.gf4bc123cb7-goog > Applied, thanks. -- Luiz Augusto von Dentz