diff options
author | Martijn Coenen <maco@google.com> | 2017-11-29 18:47:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-29 18:47:25 +0000 |
commit | cbcae5af6fd0be5e7cbb94e23503c7ba00da6694 (patch) | |
tree | 163807c81847579dd44f4f13514a1ab27a38ae30 | |
parent | 546f2d306711e0da9b0386f83f0ec0aadbd4cc0e (diff) | |
parent | b88ae7fdad8878f9ec03f9c527b745ffef4a7ff8 (diff) | |
download | libhidl-android-o-mr1-iot-preview-6.tar.gz |
Merge "Don't use service notifications if we can't."android-o-mr1-iot-preview-6o-mr1-iot-preview-6
-rw-r--r-- | transport/ServiceManagement.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp index 04f7290..34e6ea4 100644 --- a/transport/ServiceManagement.cpp +++ b/transport/ServiceManagement.cpp @@ -473,6 +473,18 @@ struct Waiter : IServiceNotification { } void onFirstRef() override { + // If this process only has one binder thread, and we're calling wait() from + // that thread, it will block forever because we hung up the one and only + // binder thread on a condition variable that can only be notified by an + // incoming binder call. + if (ProcessState::self()->getMaxThreads() <= 1 && + IPCThreadState::self()->isLooperThread()) { + LOG(WARNING) << "Can't efficiently wait for " << mInterfaceName << "/" + << mInstanceName << ", because we are called from " + << "the only binder thread in this process."; + return; + } + Return<bool> ret = mSm->registerForNotifications(mInterfaceName, mInstanceName, this); if (!ret.isOk()) { |