diff options
author | 2023-10-17 15:43:36 +0000 | |
---|---|---|
committer | 2023-10-17 15:43:36 +0000 | |
commit | 2b5da9e68eba42f5ed9b0e9e8ea302b8c4e81804 (patch) | |
tree | cea8974248895cbf632b0f1e0baa124f8e3aa1f6 | |
parent | b011e55e14ae48cefdfac48f83ca4a900fba2b3b (diff) | |
parent | 442907b0f89717bc72cd9b07ce06ebfceb0ce89d (diff) |
Merge "RPC binder: set TCP_NDELAY" into main
-rw-r--r-- | libs/binder/RpcServer.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index db31737aef..07ab093992 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "RpcServer" #include <inttypes.h> +#include <netinet/tcp.h> #include <poll.h> #include <sys/socket.h> #include <sys/un.h> @@ -571,6 +572,17 @@ status_t RpcServer::setupSocketServer(const RpcSocketAddress& addr) { return -savedErrno; } + if (addr.addr()->sa_family == AF_INET || addr.addr()->sa_family == AF_INET6) { + int noDelay = 1; + int result = + setsockopt(socket_fd.get(), IPPROTO_TCP, TCP_NODELAY, &noDelay, sizeof(noDelay)); + if (result < 0) { + int savedErrno = errno; + ALOGE("Could not set TCP_NODELAY on %s", strerror(savedErrno)); + return -savedErrno; + } + } + { RpcMutexLockGuard _l(mLock); if (mServerSocketModifier != nullptr) { |