Avoid potential deadlocks in SensorService
Sensor connections are held as weak pointers in SensorService, but promoted to strong pointer with a lock held when the service needs to operate on them. They are typically destroyed by Binder when the remote end goes away, dropping the final reference count to 0. However, if a remote dies while the service is holding an sp on the connection, the destructor will be invoked when the local object goes out of scope. If this happens with the lock held, the system will deadlock as the destructor attempts to acquire the same lock. Fix all occurrences of this in SensorService by creating two wrapper classes: one that exposes only write access to the connection lists, and one that returns a copy of a connection list, with elements promoted to sp, and holds onto the sp references until the lock is released. Bug: 137369322 Test: run sensors CTS Change-Id: I68136819cc63ab54071f523d3e8b1318adf03e7e
Loading
Please register or sign in to comment