summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2017-06-29 22:29:36 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-29 22:29:36 +0000
commit51741d2f5037c9f00171b3c1910ff170dc497dcf (patch)
treeaa8c12c85a052cee43ed8d7b050cd276acb14430 /healthd
parente1a58a8c5c77e4eab4bb9f7bad91ab343d186dc8 (diff)
parente29a6cda3127b40f4b9ecc9aab4d52285a989a10 (diff)
downloadsystem_core-51741d2f5037c9f00171b3c1910ff170dc497dcf.tar.gz
system_core-51741d2f5037c9f00171b3c1910ff170dc497dcf.tar.bz2
system_core-51741d2f5037c9f00171b3c1910ff170dc497dcf.zip
Merge "healthd: notify listeners using local copy of list, drop lock"
am: e29a6cda31 Change-Id: I94c6b076148c65e82ef13fc75b4be15b3e930901
Diffstat (limited to 'healthd')
-rw-r--r--healthd/BatteryPropertiesRegistrar.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index 523e1f136..e51a06d5e 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -36,9 +36,19 @@ void BatteryPropertiesRegistrar::publish(
}
void BatteryPropertiesRegistrar::notifyListeners(const struct BatteryProperties& props) {
- Mutex::Autolock _l(mRegistrationLock);
- for (size_t i = 0; i < mListeners.size(); i++) {
- mListeners[i]->batteryPropertiesChanged(props);
+ Vector<sp<IBatteryPropertiesListener> > listenersCopy;
+
+ // Binder currently may service an incoming oneway transaction whenever an
+ // outbound oneway call is made (if there is already a pending incoming
+ // oneway call waiting). This is considered a bug and may change in the
+ // future. For now, avoid recursive mutex lock while making outbound
+ // calls by making a local copy of the current list of listeners.
+ {
+ Mutex::Autolock _l(mRegistrationLock);
+ listenersCopy = mListeners;
+ }
+ for (size_t i = 0; i < listenersCopy.size(); i++) {
+ listenersCopy[i]->batteryPropertiesChanged(props);
}
}