diff options
Diffstat (limited to 'libs/binder/RpcState.cpp')
-rw-r--r-- | libs/binder/RpcState.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 32b4b78675..b5eaaa3413 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -26,12 +26,28 @@ #include "Debug.h" #include "RpcWireFormat.h" +#include <random> + #include <inttypes.h> namespace android { using base::ScopeGuard; +#ifdef RPC_FLAKE_PRONE +void rpcMaybeWaitToFlake() { + static std::random_device r; + static std::mutex m; + + unsigned num; + { + std::lock_guard<std::mutex> lock(m); + num = r(); + } + if (num % 10 == 0) usleep(num % 1000); +} +#endif + RpcState::RpcState() {} RpcState::~RpcState() {} @@ -260,6 +276,8 @@ status_t RpcState::rpcSend(const sp<RpcSession::RpcConnection>& connection, LOG_RPC_DETAIL("Sending %s on fd %d: %s", what, connection->fd.get(), hexString(data, size).c_str()); + MAYBE_WAIT_IN_FLAKE_MODE; + if (size > std::numeric_limits<ssize_t>::max()) { ALOGE("Cannot send %s at size %zu (too big)", what, size); (void)session->shutdownAndWait(false); |