libbinder: RPC explicit check when out of async IDs
There are far more IDs in a uint64_t than is reasonable to be called on
a binder (commented in the CL, 1000 oneway transactions per second for
585 million years to a single binder). If necessary, we could remove
this limit by rotating the IDs (no more than 2**64 simultaneous
transactions to a single binder). However, there are more critical
problems to handle, so leaving this as-is for now.
Bug: 183140903
Test: binderRpcTest
Change-Id: I5fe33278c965745e31fc0b14a21626a4c680fa70
diff --git a/libs/binder/RpcState.h b/libs/binder/RpcState.h
index 2654dff..81ff458 100644
--- a/libs/binder/RpcState.h
+++ b/libs/binder/RpcState.h
@@ -113,6 +113,9 @@
void terminate();
private:
+ void dumpLocked();
+ void terminate(std::unique_lock<std::mutex>& lock);
+
// Alternative to std::vector<uint8_t> that doesn't abort on allocation failure and caps
// large allocations to avoid being requested from allocating too much data.
struct CommandData {
@@ -200,6 +203,10 @@
// binderNode, this returns that strong reference, so that it can be
// dropped after any locks are removed.
sp<IBinder> tryEraseNode(std::map<RpcAddress, BinderNode>::iterator& it);
+ // true - success
+ // false - state terminated, lock gone, halt
+ [[nodiscard]] bool nodeProgressAsyncNumber(BinderNode* node,
+ std::unique_lock<std::mutex>& lock);
std::mutex mNodeMutex;
bool mTerminated = false;