Loading libs/binder/IServiceManager.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -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, [&] { Loading @@ -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. Loading @@ -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()); } } Loading Loading
libs/binder/IServiceManager.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -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, [&] { Loading @@ -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. Loading @@ -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()); } } Loading