service: Solve locking issues inside GATT interface
ObserverList class handles adding/removing elements during iteration
by itself, therefore we don't need to do any locking.
Additionally, change lock type to shared for better performance, and
to avoid possible deadlocks that might be caused by calling HAL from
observers.
Change-Id: I4c372f1e03bd27a96bc6c036ab8ce34f5501c0a7
diff --git a/service/gatt_server.cpp b/service/gatt_server.cpp
index 753efca..e70f093 100644
--- a/service/gatt_server.cpp
+++ b/service/gatt_server.cpp
@@ -1008,9 +1008,7 @@
if (status == BT_STATUS_SUCCESS) {
server.reset(new GattServer(uuid, server_id));
- // Use the unsafe variant to register this as an observer to prevent a
- // deadlock since this callback is currently holding the lock.
- gatt_iface->AddServerObserverUnsafe(server.get());
+ gatt_iface->AddServerObserver(server.get());
result = BLE_STATUS_SUCCESS;
}