Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34a07f99 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libbinder: RPC - remove 'agreed experimental'" am: 00e21718

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1861915

Change-Id: I704e7ec29b12abe8aec4c7d3567db7f5aafa3122
parents 3788f049 00e21718
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -547,7 +547,6 @@ status_t BBinder::setRpcClientDebug(android::base::unique_fd socketFd,
    AutoMutex _l(e->mLock);
    AutoMutex _l(e->mLock);
    auto rpcServer = RpcServer::make();
    auto rpcServer = RpcServer::make();
    LOG_ALWAYS_FATAL_IF(rpcServer == nullptr, "RpcServer::make returns null");
    LOG_ALWAYS_FATAL_IF(rpcServer == nullptr, "RpcServer::make returns null");
    rpcServer->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
    auto link = sp<RpcServerLink>::make(rpcServer, keepAliveBinder, weakThis);
    auto link = sp<RpcServerLink>::make(rpcServer, keepAliveBinder, weakThis);
    if (auto status = keepAliveBinder->linkToDeath(link, nullptr, 0); status != OK) {
    if (auto status = keepAliveBinder->linkToDeath(link, nullptr, 0); status != OK) {
        ALOGE("%s: keepAliveBinder->linkToDeath returns %s", __PRETTY_FUNCTION__,
        ALOGE("%s: keepAliveBinder->linkToDeath returns %s", __PRETTY_FUNCTION__,
+0 −12
Original line number Original line Diff line number Diff line
@@ -58,10 +58,6 @@ sp<RpcServer> RpcServer::make(std::unique_ptr<RpcTransportCtxFactory> rpcTranspo
    return sp<RpcServer>::make(std::move(ctx));
    return sp<RpcServer>::make(std::move(ctx));
}
}


void RpcServer::iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction() {
    mAgreedExperimental = true;
}

status_t RpcServer::setupUnixDomainServer(const char* path) {
status_t RpcServer::setupUnixDomainServer(const char* path) {
    return setupSocketServer(UnixSocketAddress(path));
    return setupSocketServer(UnixSocketAddress(path));
}
}
@@ -163,14 +159,12 @@ static void joinRpcServer(sp<RpcServer>&& thiz) {
}
}


void RpcServer::start() {
void RpcServer::start() {
    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
    std::lock_guard<std::mutex> _l(mLock);
    std::lock_guard<std::mutex> _l(mLock);
    LOG_ALWAYS_FATAL_IF(mJoinThread.get(), "Already started!");
    LOG_ALWAYS_FATAL_IF(mJoinThread.get(), "Already started!");
    mJoinThread = std::make_unique<std::thread>(&joinRpcServer, sp<RpcServer>::fromExisting(this));
    mJoinThread = std::make_unique<std::thread>(&joinRpcServer, sp<RpcServer>::fromExisting(this));
}
}


void RpcServer::join() {
void RpcServer::join() {
    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");


    {
    {
        std::lock_guard<std::mutex> _l(mLock);
        std::lock_guard<std::mutex> _l(mLock);
@@ -274,9 +268,6 @@ size_t RpcServer::numUninitializedSessions() {


void RpcServer::establishConnection(sp<RpcServer>&& server, base::unique_fd clientFd,
void RpcServer::establishConnection(sp<RpcServer>&& server, base::unique_fd clientFd,
                                    const sockaddr_storage addr, socklen_t addrLen) {
                                    const sockaddr_storage addr, socklen_t addrLen) {
    // TODO(b/183988761): cannot trust this simple ID
    LOG_ALWAYS_FATAL_IF(!server->mAgreedExperimental, "no!");

    // mShutdownTrigger can only be cleared once connection threads have joined.
    // mShutdownTrigger can only be cleared once connection threads have joined.
    // It must be set before this thread is started
    // It must be set before this thread is started
    LOG_ALWAYS_FATAL_IF(server->mShutdownTrigger == nullptr);
    LOG_ALWAYS_FATAL_IF(server->mShutdownTrigger == nullptr);
@@ -506,19 +497,16 @@ void RpcServer::onSessionIncomingThreadEnded() {
}
}


bool RpcServer::hasServer() {
bool RpcServer::hasServer() {
    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
    std::lock_guard<std::mutex> _l(mLock);
    std::lock_guard<std::mutex> _l(mLock);
    return mServer.ok();
    return mServer.ok();
}
}


unique_fd RpcServer::releaseServer() {
unique_fd RpcServer::releaseServer() {
    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
    std::lock_guard<std::mutex> _l(mLock);
    std::lock_guard<std::mutex> _l(mLock);
    return std::move(mServer);
    return std::move(mServer);
}
}


status_t RpcServer::setupExternalServer(base::unique_fd serverFd) {
status_t RpcServer::setupExternalServer(base::unique_fd serverFd) {
    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
    std::lock_guard<std::mutex> _l(mLock);
    std::lock_guard<std::mutex> _l(mLock);
    if (mServer.ok()) {
    if (mServer.ok()) {
        ALOGE("Each RpcServer can only have one server.");
        ALOGE("Each RpcServer can only have one server.");
+0 −7
Original line number Original line Diff line number Diff line
@@ -25,10 +25,6 @@
#include <mutex>
#include <mutex>
#include <thread>
#include <thread>


// WARNING: This is a feature which is still in development, and it is subject
// to radical change. Any production use of this may subject your code to any
// number of problems.

namespace android {
namespace android {


class FdTrigger;
class FdTrigger;
@@ -99,8 +95,6 @@ public:
     */
     */
    [[nodiscard]] status_t setupExternalServer(base::unique_fd serverFd);
    [[nodiscard]] status_t setupExternalServer(base::unique_fd serverFd);


    void iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();

    /**
    /**
     * This must be called before adding a client session.
     * This must be called before adding a client session.
     *
     *
@@ -188,7 +182,6 @@ private:
    status_t setupSocketServer(const RpcSocketAddress& address);
    status_t setupSocketServer(const RpcSocketAddress& address);


    const std::unique_ptr<RpcTransportCtx> mCtx;
    const std::unique_ptr<RpcTransportCtx> mCtx;
    bool mAgreedExperimental = false;
    size_t mMaxThreads = 1;
    size_t mMaxThreads = 1;
    std::optional<uint32_t> mProtocolVersion;
    std::optional<uint32_t> mProtocolVersion;
    base::unique_fd mServer; // socket we are accepting sessions on
    base::unique_fd mServer; // socket we are accepting sessions on
+0 −4
Original line number Original line Diff line number Diff line
@@ -26,10 +26,6 @@
#include <thread>
#include <thread>
#include <vector>
#include <vector>


// WARNING: This is a feature which is still in development, and it is subject
// to radical change. Any production use of this may subject your code to any
// number of problems.

namespace android {
namespace android {


class Parcel;
class Parcel;
+0 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,6 @@ extern "C" {
bool RunRpcServerCallback(AIBinder* service, unsigned int port, void (*readyCallback)(void* param),
bool RunRpcServerCallback(AIBinder* service, unsigned int port, void (*readyCallback)(void* param),
                          void* param) {
                          void* param) {
    auto server = RpcServer::make();
    auto server = RpcServer::make();
    server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
    if (status_t status = server->setupVsockServer(port); status != OK) {
    if (status_t status = server->setupVsockServer(port); status != OK) {
        LOG(ERROR) << "Failed to set up vsock server with port " << port
        LOG(ERROR) << "Failed to set up vsock server with port " << port
                   << " error: " << statusToString(status).c_str();
                   << " error: " << statusToString(status).c_str();
Loading