OSDN Git Service
(root)
/
android-x86
/
frameworks-native.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
09034f0
)
Fix race condition for SensorManager looper.
author
Yifan Hong
<elsk@google.com>
Wed, 14 Jun 2017 01:04:25 +0000
(18:04 -0700)
committer
Yifan Hong
<elsk@google.com>
Wed, 14 Jun 2017 01:56:07 +0000
(18:56 -0700)
Before the fix there could be two background threads started for two
loopers. Add a guard to prevent this from happening.
Test: pass
Bug:
62404135
Change-Id: I8230addaaa6b83670d7b83c96809b00fca95d352
services/sensorservice/hidl/SensorManager.cpp
patch
|
blob
|
history
diff --git
a/services/sensorservice/hidl/SensorManager.cpp
b/services/sensorservice/hidl/SensorManager.cpp
index
004a5c5
..
25a3dc5
100644
(file)
--- a/
services/sensorservice/hidl/SensorManager.cpp
+++ b/
services/sensorservice/hidl/SensorManager.cpp
@@
-143,6
+143,10
@@
sp<::android::Looper> SensorManager::getLooper() {
}
std::unique_lock<std::mutex> lock(mutex);
+ if (looper != nullptr) {
+ LOG(INFO) << "Another thread has already set the looper, exiting this one.";
+ return;
+ }
looper = Looper::prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS /* opts */);
lock.unlock();