binder: allow repeated invocations of initWithDriver
As long as the driver name is the same, calls to
ProcessState::initWithDriver() will succeed, returning the
already-created object.
Test: marlin
Change-Id: I87d5ca2a105becd8d4fa6fa85c00b879360229b3
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 9ccf07c..add5e74 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -79,6 +79,11 @@
{
Mutex::Autolock _l(gProcessMutex);
if (gProcess != NULL) {
+ // Allow for initWithDriver to be called repeatedly with the same
+ // driver.
+ if (!strcmp(gProcess->getDriverName().c_str(), driver)) {
+ return gProcess;
+ }
LOG_ALWAYS_FATAL("ProcessState was already initialized.");
}
gProcess = new ProcessState(driver);