Fix race condition in bluez discovery operations

This guards StartDiscovery from happening when StopDiscovery is still in
progress and guards StopDiscovery from happening when StartDiscovery is
still in progress.

BUG=chromium:765392,chromium:738237
TEST=Add intentional delay in kernel's MGMT_OP_START_DISCOVERY so race
condition can be reproduced and check that bluez returns error Busy
instead of letting the race condition happen.
CQ-DEPEND=CL:677466

Change-Id: I29da033aa9139312f7ef09727f31154a25650d49
Reviewed-on: https://chromium-review.googlesource.com/677467
Commit-Ready: Sonny Sasaka <sonnysasaka@chromium.org>
Tested-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Dmitry Grinberg <dmitrygr@google.com>
(cherry picked from commit 4baf6005b854802bfea07c8142179dbf31ea7561)
Reviewed-on: https://chromium-review.googlesource.com/679114
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
1 file changed