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 53eba5aea6..69ada56ed0 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() {} @@ -226,6 +242,8 @@ status_t RpcState::rpcSend(const base::unique_fd& fd, const sp<RpcSession>& sess const char* what, const void* data, size_t size) { LOG_RPC_DETAIL("Sending %s on fd %d: %s", what, 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); |