binder: RpcTranpsortCtx::newTransport Add FdTrigger arg.
For TLS, creating a new RpcTransport object may require I/O.
Make them interruptable by providing an FdTrigger argument.
Test: binderRpcTest
Bug: 190868302
Change-Id: I63a6655f50d1b2fa5a484860ec422021e88de3e5
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index a0c508b..a20445b 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -260,7 +260,7 @@
status_t status = OK;
int clientFdForLog = clientFd.get();
- auto client = server->mCtx->newTransport(std::move(clientFd));
+ auto client = server->mCtx->newTransport(std::move(clientFd), server->mShutdownTrigger.get());
if (client == nullptr) {
ALOGE("Dropping accept4()-ed socket because sslAccept fails");
status = DEAD_OBJECT;
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index 7799da2..4ee0128 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -160,7 +160,7 @@
ALOGE("Unable to create RpcTransportCtx for null debugging client");
return NO_MEMORY;
}
- auto server = ctx->newTransport(std::move(serverFd));
+ auto server = ctx->newTransport(std::move(serverFd), mShutdownTrigger.get());
if (server == nullptr) {
ALOGE("Unable to set up RpcTransport");
return UNKNOWN_ERROR;
@@ -536,7 +536,7 @@
mRpcTransportCtxFactory->toCString());
return NO_MEMORY;
}
- auto server = ctx->newTransport(std::move(fd));
+ auto server = ctx->newTransport(std::move(fd), mShutdownTrigger.get());
if (server == nullptr) {
ALOGE("Unable to set up RpcTransport in %s context", mRpcTransportCtxFactory->toCString());
return UNKNOWN_ERROR;
diff --git a/libs/binder/RpcTransportRaw.cpp b/libs/binder/RpcTransportRaw.cpp
index 46170f7..d77fc52 100644
--- a/libs/binder/RpcTransportRaw.cpp
+++ b/libs/binder/RpcTransportRaw.cpp
@@ -108,7 +108,7 @@
// RpcTransportCtx with TLS disabled.
class RpcTransportCtxRaw : public RpcTransportCtx {
public:
- std::unique_ptr<RpcTransport> newTransport(android::base::unique_fd fd) const {
+ std::unique_ptr<RpcTransport> newTransport(android::base::unique_fd fd, FdTrigger*) const {
return std::make_unique<RpcTransportRaw>(std::move(fd));
}
};
diff --git a/libs/binder/include/binder/RpcTransport.h b/libs/binder/include/binder/RpcTransport.h
index afca585..1b69519 100644
--- a/libs/binder/include/binder/RpcTransport.h
+++ b/libs/binder/include/binder/RpcTransport.h
@@ -56,8 +56,13 @@
class RpcTransportCtx {
public:
virtual ~RpcTransportCtx() = default;
+
+ // Create a new RpcTransport object.
+ //
+ // Implemenion details: for TLS, this function may incur I/O. |fdTrigger| may be used
+ // to interrupt I/O. This function blocks until handshake is finished.
[[nodiscard]] virtual std::unique_ptr<RpcTransport> newTransport(
- android::base::unique_fd fd) const = 0;
+ android::base::unique_fd fd, FdTrigger *fdTrigger) const = 0;
protected:
RpcTransportCtx() = default;