From: Martijn Coenen Date: Thu, 11 May 2017 16:45:59 +0000 (-0700) Subject: Only spawn one binder thread for cmd. X-Git-Tag: android-x86-9.0-r1~417^2^2~59^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c21bc9afe403f52c189d2d6b79dedaf9dce6217b;p=android-x86%2Fframeworks-native.git Only spawn one binder thread for cmd. To work around race conditions in libbinder when spawning new threads while being shut down. Bug: 36066697 Test: cmd still works Change-Id: I71c8d1aac29a1bf65d54023a4ed39d943ad54c98 --- diff --git a/cmds/cmd/cmd.cpp b/cmds/cmd/cmd.cpp index 73d274fbb8..7e05d72eae 100644 --- a/cmds/cmd/cmd.cpp +++ b/cmds/cmd/cmd.cpp @@ -123,6 +123,13 @@ int main(int argc, char* const argv[]) { signal(SIGPIPE, SIG_IGN); sp proc = ProcessState::self(); + // setThreadPoolMaxThreadCount(0) actually tells the kernel it's + // not allowed to spawn any additional threads, but we still spawn + // a binder thread from userspace when we call startThreadPool(). + // This is safe because we only have 2 callbacks, neither of which + // block. + // See b/36066697 for rationale + proc->setThreadPoolMaxThreadCount(0); proc->startThreadPool(); sp sm = defaultServiceManager();