diff options
| author | 2021-05-12 17:07:36 -0700 | |
|---|---|---|
| committer | 2021-05-13 20:16:09 -0700 | |
| commit | 00aeb76928c7bd4c6455ff959ed3cc3bce69a73d (patch) | |
| tree | d74ca77fc2e8390163d4c40eda72972cbcced7ff /libs/binder/RpcServer.cpp | |
| parent | 95f88e71c329fb8dbff134a690600de752b9f384 (diff) | |
RpcServer: expose server fd
Add a few functions that allows to expose the socket()
fd, because socket() and accept() may be called
in different processes.
Test: binderRpcTest
Test: binderLibTest
Bug: 182914638
Change-Id: I5489516fc92977aca4c98ee2dcdfa8365f8740c9
Diffstat (limited to 'libs/binder/RpcServer.cpp')
| -rw-r--r-- | libs/binder/RpcServer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp index dc10d1c524..9cc6e7fe04 100644 --- a/libs/binder/RpcServer.cpp +++ b/libs/binder/RpcServer.cpp @@ -272,8 +272,26 @@ void RpcServer::onSessionTerminating(const sp<RpcSession>& session) { } bool RpcServer::hasServer() { + LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!"); std::lock_guard<std::mutex> _l(mLock); return mServer.ok(); } +unique_fd RpcServer::releaseServer() { + LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!"); + std::lock_guard<std::mutex> _l(mLock); + return std::move(mServer); +} + +bool RpcServer::setupExternalServer(base::unique_fd serverFd) { + LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!"); + std::lock_guard<std::mutex> _l(mLock); + if (mServer.ok()) { + ALOGE("Each RpcServer can only have one server."); + return false; + } + mServer = std::move(serverFd); + return true; +} + } // namespace android |