libbinder: detect bad linkToDeath
If linkToDeath is called without any threads listening for binder
transactions, then it may not be served. This is a hard to debug
issue, so adding a log.
Bug: 237730299
Test: boot, and see these logs (they occur in cameraserver which sets
up the threadpool late. this is not an issue, but the ordering could
be 'nicer'):
07-12 20:52:26.537 515 515 W BpBinder: Linking to death on android.app.IActivityManager but there are no threads (yet?) listening to incoming transactions. See ProcessState::startThreadPool and ProcessState::setThreadPoolMaxThreadCount. Generally you should setup the binder threadpool before other initialization steps.
07-12 20:52:26.673 515 515 W BpBinder: Linking to death on android.hardware.ISensorPrivacyManager but there are no threads (yet?) listening to incoming transactions. See ProcessState::startThreadPool and ProcessState::setThreadPoolMaxThreadCount. Generally you should setup the binder threadpool before other initialization steps.
Change-Id: I8c2bb308f4bd479000e644a785d8c27341ad496a
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 49fc195..82ebdd7 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -358,6 +358,14 @@
LOG_ALWAYS_FATAL_IF(recipient == nullptr,
"linkToDeath(): recipient must be non-NULL");
+ if (ProcessState::self()->getThreadPoolMaxTotalThreadCount() == 0) {
+ ALOGW("Linking to death on %s but there are no threads (yet?) listening to incoming "
+ "transactions. See ProcessState::startThreadPool and "
+ "ProcessState::setThreadPoolMaxThreadCount. Generally you should setup the binder "
+ "threadpool before other initialization steps.",
+ String8(getInterfaceDescriptor()).c_str());
+ }
+
{
AutoMutex _l(mLock);