Loading libs/binder/RpcSession.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,8 @@ status_t RpcSession::FdTrigger::interruptableReadFully(base::borrowed_fd fd, voi uint8_t* buffer = reinterpret_cast<uint8_t*>(data); uint8_t* end = buffer + size; MAYBE_WAIT_IN_FLAKE_MODE; status_t status; while ((status = triggerablePollRead(fd)) == OK) { ssize_t readSize = TEMP_FAILURE_RETRY(recv(fd.get(), buffer, end - buffer, MSG_NOSIGNAL)); Loading libs/binder/RpcState.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -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() {} Loading Loading @@ -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); Loading libs/binder/RpcState.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,15 @@ struct RpcWireHeader; #define LOG_RPC_DETAIL(...) ALOGV(__VA_ARGS__) // for type checking #endif #define RPC_FLAKE_PRONE false #ifdef RPC_FLAKE_PRONE void rpcMaybeWaitToFlake(); #define MAYBE_WAIT_IN_FLAKE_MODE rpcMaybeWaitToFlake() #else #define MAYBE_WAIT_IN_FLAKE_MODE do {} while (false) #endif /** * Abstracts away management of ref counts and the wire format from * RpcSession Loading Loading
libs/binder/RpcSession.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,8 @@ status_t RpcSession::FdTrigger::interruptableReadFully(base::borrowed_fd fd, voi uint8_t* buffer = reinterpret_cast<uint8_t*>(data); uint8_t* end = buffer + size; MAYBE_WAIT_IN_FLAKE_MODE; status_t status; while ((status = triggerablePollRead(fd)) == OK) { ssize_t readSize = TEMP_FAILURE_RETRY(recv(fd.get(), buffer, end - buffer, MSG_NOSIGNAL)); Loading
libs/binder/RpcState.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -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() {} Loading Loading @@ -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); Loading
libs/binder/RpcState.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,15 @@ struct RpcWireHeader; #define LOG_RPC_DETAIL(...) ALOGV(__VA_ARGS__) // for type checking #endif #define RPC_FLAKE_PRONE false #ifdef RPC_FLAKE_PRONE void rpcMaybeWaitToFlake(); #define MAYBE_WAIT_IN_FLAKE_MODE rpcMaybeWaitToFlake() #else #define MAYBE_WAIT_IN_FLAKE_MODE do {} while (false) #endif /** * Abstracts away management of ref counts and the wire format from * RpcSession Loading