diff options
author | 2020-07-15 22:26:08 +0000 | |
---|---|---|
committer | 2020-07-15 22:26:08 +0000 | |
commit | ea8305102a6cdd1b2cf89b1f020391bd19f71244 (patch) | |
tree | 9ff51fef9e948b11aa545f4543848d1d462bd65b | |
parent | 6725fe4aa96396ae8caba8c573d978322f37b6a9 (diff) | |
parent | f2677e2cdeb7c18b4ecbbd0ac789a0fe8f5e5b2a (diff) |
Merge "libbinder: add hints to waitForService error"
-rw-r--r-- | libs/binder/IServiceManager.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 05f43e3658..25c0b1944e 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -326,6 +326,11 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16) while(true) { { + // It would be really nice if we could read binder commands on this + // thread instead of needing a threadpool to be started, but for + // instance, if we call getAndExecuteCommand, it might be the case + // that another thread serves the callback, and we never get a + // command, so we hang indefinitely. std::unique_lock<std::mutex> lock(waiter->mMutex); using std::literals::chrono_literals::operator""s; waiter->mCv.wait_for(lock, 1s, [&] { @@ -334,6 +339,8 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16) if (waiter->mBinder != nullptr) return waiter->mBinder; } + ALOGW("Waited one second for %s (is service started? are binder threads started and available?)", name.c_str()); + // Handle race condition for lazy services. Here is what can happen: // - the service dies (not processed by init yet). // - sm processes death notification. @@ -347,8 +354,6 @@ sp<IBinder> ServiceManagerShim::waitForService(const String16& name16) return nullptr; } if (out != nullptr) return out; - - ALOGW("Waited one second for %s", name.c_str()); } } |