Destroy DeviceWatcher _after_ stopping discovery.

This lets DeviceWatcher receive InterfacesRemoved signals so that we
can potentially get rid of lost devices.
This commit is contained in:
Vibhav Pant
2023-09-09 21:58:18 +05:30
parent f489a179a6
commit c7a5bdcebb
2 changed files with 9 additions and 7 deletions
@@ -419,16 +419,17 @@ BleV2Medium::StartScanning(const Uuid &service_uuid,
<< "' and message '" << e.getMessage() << "'";
}
active_adv_monitors_.erase(service_uuid);
auto &adapter = adapter_.GetBluezAdapterObject();
absl::Status status;
try {
adapter.StopDiscovery();
status = absl::OkStatus();
} catch (const sdbus::Error &e) {
DBUS_LOG_METHOD_CALL_ERROR(&adapter, "StopDiscovery", e);
return absl::InternalError(e.getMessage());
status = absl::InternalError(e.getMessage());
}
return absl::OkStatus();
active_adv_monitors_.erase(service_uuid);
return status;
}});
}