libbinder: fix RPC setup races
When setting up connections, there are a few cases where we take the server lock and then we take the session lock. However, when a session is shutting down, there is one case where we took the session lock and then the server lock. This is a big no-no, and it was causing a deadlock in the 'Fds' test (this creates many threads - but it is very shortlived, the threads are still being setup on the server when the process shutsdown, hitting the deadlock occassionally). The solution to this involves keeping a little bit of extra state inside of RpcSession directly to understand when it's shutting down. Also, we now fully cleanup sessions before removing them during the shutdown process. From this point on, we should always take the server lock and then the session lock in order to avoid races (never the session and then the server). Bug: N/A Test: binderRpcTest Test: while $ANDROID_BUILD_TOP/out/host/linux-x86/nativetest/binderRpcTest/binderRpcTest --gtest_filter="*Fd*"; do : ; done Change-Id: I9144c43939c0640a2ec53f93f6e685ddce4b3e83
Loading
Please register or sign in to comment