Skip to content
Permalink
Browse files

[Bluetooth] Remove IsDiscovering() check in StopScan().

Always request bluez to stop discovery; do not gate on whether or not
discovery is active.

The recent refactor crrev.com/c/1699214 in BluetoothAdapter and its
children classes resurfaced a buggy implementation of
BluetoothAdapterBluez::IsDiscovering() (crbug.com/905374) -- its
implementation in bluez can sometimes return an incorrect value. In this
particular bug, crbug.com/1013020, when ARC++ spammed BluetoothAdapterBluez
with too many Start/Stop scan calls, we entered a racy situation in which
ARC++ called StopScan(), and that StopScan() incorrectly early-returned,
failing to stop discovery, because BluetoothAdapterBluez::IsDiscovering()
incorrectly returned 'false'.

      the repro steps described in crbug.com/1013020.

(cherry picked from commit 90f5556)

Bug: 1013020, 822104, 905374
TEST: Manaully verified 5 times on both M78 branch and ToT following
Change-Id: Ide80706d77f1659cc07f457c4a524d823141f2c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854459
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#704863}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1856240
Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/branch-heads/3904@{#732}
Cr-Branched-From: 675968a-refs/heads/master@{#693954}
  • Loading branch information
Ryan Hansberry
Ryan Hansberry committed Oct 11, 2019
1 parent 5227e61 commit 262c1c1556313564a28e590ec558ca99a5ee5817
Showing with 0 additions and 6 deletions.
  1. +0 −6 device/bluetooth/bluez/bluetooth_adapter_bluez.cc
@@ -1575,12 +1575,6 @@ void BluetoothAdapterBlueZ::StopScan(DiscoverySessionResultCallback callback) {

DCHECK_EQ(NumDiscoverySessions(), 0);

if (!IsDiscovering()) {
std::move(callback).Run(
/*is_error=*/false, UMABluetoothDiscoverySessionOutcome::SUCCESS);
return;
}

// Confirm that there are no more discovery sessions left.
DCHECK_EQ(NumDiscoverySessions(), 0);
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));

0 comments on commit 262c1c1

Please sign in to comment.
You can’t perform that action at this time.