summaryrefslogtreecommitdiff
path: root/libs/binder/RpcServer.cpp
diff options
context:
space:
mode:
author Yifan Hong <elsk@google.com> 2021-08-05 16:37:17 -0700
committer Yifan Hong <elsk@google.com> 2021-08-06 12:09:40 -0700
commitb675ffe41b574bd7a13ebbc8682cf147508b5c21 (patch)
tree563138d017c6ccd0b587876c2c8bc66133b6bce1 /libs/binder/RpcServer.cpp
parent8c950421dbe8d9c2cea5e293b925b01d6f8c52da (diff)
binder: RPC uses non-blocking sockets.
With TLS, even though poll() may have returned for an FD, there may not be a complete packet available, so I/O operations within libssl may block and not interruptible by the shutdown trigger. Hence, always use non-blocking sockets. Test: binderRpcTest Bug: 195683291 Change-Id: I372e8c3bf010c672b1c4b9f7cb5b789ca20c9480
Diffstat (limited to 'libs/binder/RpcServer.cpp')
-rw-r--r--libs/binder/RpcServer.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index 66483edffb..a0c508be03 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -168,7 +168,7 @@ void RpcServer::join() {
status_t status;
while ((status = mShutdownTrigger->triggerablePoll(mServer, POLLIN)) == OK) {
unique_fd clientFd(TEMP_FAILURE_RETRY(
- accept4(mServer.get(), nullptr, nullptr /*length*/, SOCK_CLOEXEC)));
+ accept4(mServer.get(), nullptr, nullptr /*length*/, SOCK_CLOEXEC | SOCK_NONBLOCK)));
if (clientFd < 0) {
ALOGE("Could not accept4 socket: %s", strerror(errno));
@@ -388,8 +388,8 @@ status_t RpcServer::setupSocketServer(const RpcSocketAddress& addr) {
LOG_RPC_DETAIL("Setting up socket server %s", addr.toString().c_str());
LOG_ALWAYS_FATAL_IF(hasServer(), "Each RpcServer can only have one server.");
- unique_fd serverFd(
- TEMP_FAILURE_RETRY(socket(addr.addr()->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0)));
+ unique_fd serverFd(TEMP_FAILURE_RETRY(
+ socket(addr.addr()->sa_family, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)));
if (serverFd == -1) {
int savedErrno = errno;
ALOGE("Could not create socket: %s", strerror(savedErrno));