summaryrefslogtreecommitdiff
path: root/libs/binder/RpcServer.cpp
diff options
context:
space:
mode:
author Keith Mok <keithmok@google.com> 2023-10-11 20:36:18 +0000
committer Keith Mok <keithmok@google.com> 2023-10-13 18:38:10 +0000
commit442907b0f89717bc72cd9b07ce06ebfceb0ce89d (patch)
treea6373518c74cfaab4f837a845f99e84b2629d3d3 /libs/binder/RpcServer.cpp
parent0b3e8b2ae37f2e51f3ade5dd5c8731390f7eaa63 (diff)
RPC binder: set TCP_NDELAY
System by default cache TCP data trying to pack more data before sending out to the wire, this cause delay in rpc communication. Currently we set TCP_NDELAY in RpcSession, but not in RpcServer. This CL add TCP_NDELAY to RpcServer also. Bug: 304823925 Test: manual Change-Id: I8bfda370a78eff9b8e0ab75e6bc2fd0a5ba743ed
Diffstat (limited to 'libs/binder/RpcServer.cpp')
-rw-r--r--libs/binder/RpcServer.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 55fc16de45..03dad2baca 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>
@@ -572,6 +573,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) {