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.

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.

Change-Id: I29da033aa9139312f7ef09727f31154a25650d49
Commit-Ready: Sonny Sasaka <>
Tested-by: Sonny Sasaka <>
Reviewed-by: Miao-chen Chou <>
Reviewed-by: Dmitry Grinberg <>
(cherry picked from commit 4baf6005b854802bfea07c8142179dbf31ea7561)
Reviewed-by: Sonny Sasaka <>
Commit-Queue: Sonny Sasaka <>
1 file changed