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

Commit 3c83e0b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I2a437363,I27226885 into main am: 9636af27

parents c24b9e9e 9636af27
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -22,11 +22,13 @@
#include <poll.h>
#include <poll.h>


#include <android-base/macros.h>
#include <android-base/macros.h>
#include <android-base/scopeguard.h>
#include <binder/Functional.h>


#include "RpcState.h"
#include "RpcState.h"
namespace android {
namespace android {


using namespace android::binder::impl;

std::unique_ptr<FdTrigger> FdTrigger::make() {
std::unique_ptr<FdTrigger> FdTrigger::make() {
    auto ret = std::make_unique<FdTrigger>();
    auto ret = std::make_unique<FdTrigger>();
#ifndef BINDER_RPC_SINGLE_THREADED
#ifndef BINDER_RPC_SINGLE_THREADED
@@ -74,8 +76,7 @@ status_t FdTrigger::triggerablePoll(const android::RpcTransportFd& transportFd,
                        "Only one thread should be polling on Fd!");
                        "Only one thread should be polling on Fd!");


    transportFd.setPollingState(true);
    transportFd.setPollingState(true);
    auto pollingStateGuard =
    auto pollingStateGuard = make_scope_guard([&]() { transportFd.setPollingState(false); });
            android::base::make_scope_guard([&]() { transportFd.setPollingState(false); });


    int ret = TEMP_FAILURE_RETRY(poll(pfd, arraysize(pfd), -1));
    int ret = TEMP_FAILURE_RETRY(poll(pfd, arraysize(pfd), -1));
    if (ret < 0) {
    if (ret < 0) {
+4 −2
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@


#include <binder/Binder.h>
#include <binder/Binder.h>
#include <binder/BpBinder.h>
#include <binder/BpBinder.h>
#include <binder/Functional.h>
#include <binder/IPCThreadState.h>
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
#include <binder/Parcel.h>
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>
@@ -39,7 +40,6 @@
#include <binder/Status.h>
#include <binder/Status.h>
#include <binder/TextOutput.h>
#include <binder/TextOutput.h>


#include <android-base/scopeguard.h>
#ifndef BINDER_DISABLE_BLOB
#ifndef BINDER_DISABLE_BLOB
#include <cutils/ashmem.h>
#include <cutils/ashmem.h>
#endif
#endif
@@ -94,6 +94,8 @@ static size_t pad_size(size_t s) {


namespace android {
namespace android {


using namespace android::binder::impl;

// many things compile this into prebuilts on the stack
// many things compile this into prebuilts on the stack
#ifdef __LP64__
#ifdef __LP64__
static_assert(sizeof(Parcel) == 120);
static_assert(sizeof(Parcel) == 120);
@@ -586,7 +588,7 @@ status_t Parcel::appendFrom(const Parcel* parcel, size_t offset, size_t len) {
        }
        }


        const size_t savedDataPos = mDataPos;
        const size_t savedDataPos = mDataPos;
        base::ScopeGuard scopeGuard = [&]() { mDataPos = savedDataPos; };
        auto scopeGuard = make_scope_guard([&]() { mDataPos = savedDataPos; });


        rpcFields->mObjectPositions.reserve(otherRpcFields->mObjectPositions.size());
        rpcFields->mObjectPositions.reserve(otherRpcFields->mObjectPositions.size());
        if (otherRpcFields->mFds != nullptr) {
        if (otherRpcFields->mFds != nullptr) {
+4 −2
Original line number Original line Diff line number Diff line
@@ -19,9 +19,9 @@
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>


#include <android-base/result.h>
#include <android-base/result.h>
#include <android-base/scopeguard.h>
#include <android-base/strings.h>
#include <android-base/strings.h>
#include <binder/BpBinder.h>
#include <binder/BpBinder.h>
#include <binder/Functional.h>
#include <binder/IPCThreadState.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <binder/Stability.h>
#include <binder/Stability.h>
@@ -60,6 +60,8 @@ const char* kDefaultDriver = "/dev/binder";


namespace android {
namespace android {


using namespace android::binder::impl;

class PoolThread : public Thread
class PoolThread : public Thread
{
{
public:
public:
@@ -430,7 +432,7 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) {


size_t ProcessState::getThreadPoolMaxTotalThreadCount() const {
size_t ProcessState::getThreadPoolMaxTotalThreadCount() const {
    pthread_mutex_lock(&mThreadCountLock);
    pthread_mutex_lock(&mThreadCountLock);
    base::ScopeGuard detachGuard = [&]() { pthread_mutex_unlock(&mThreadCountLock); };
    auto detachGuard = make_scope_guard([&]() { pthread_mutex_unlock(&mThreadCountLock); });


    if (mThreadPoolStarted) {
    if (mThreadPoolStarted) {
        LOG_ALWAYS_FATAL_IF(mKernelStartedThreads > mMaxThreads + 1,
        LOG_ALWAYS_FATAL_IF(mKernelStartedThreads > mMaxThreads + 1,
+3 −2
Original line number Original line Diff line number Diff line
@@ -16,12 +16,13 @@


#include <android-base/file.h>
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/logging.h>
#include <android-base/scopeguard.h>
#include <android-base/unique_fd.h>
#include <android-base/unique_fd.h>
#include <binder/Functional.h>
#include <binder/RecordedTransaction.h>
#include <binder/RecordedTransaction.h>
#include <sys/mman.h>
#include <sys/mman.h>
#include <algorithm>
#include <algorithm>


using namespace android::binder::impl;
using android::Parcel;
using android::Parcel;
using android::base::borrowed_fd;
using android::base::borrowed_fd;
using android::base::unique_fd;
using android::base::unique_fd;
@@ -218,7 +219,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd
        size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset;
        size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset;
        void* mappedMemory =
        void* mappedMemory =
                mmap(NULL, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(), mmapPageAlignedStart);
                mmap(NULL, memoryMappedSize, PROT_READ, MAP_SHARED, fd.get(), mmapPageAlignedStart);
        auto mmap_guard = android::base::make_scope_guard(
        auto mmap_guard = make_scope_guard(
                [mappedMemory, memoryMappedSize] { munmap(mappedMemory, memoryMappedSize); });
                [mappedMemory, memoryMappedSize] { munmap(mappedMemory, memoryMappedSize); });


        transaction_checksum_t* payloadMap =
        transaction_checksum_t* payloadMap =
+5 −4
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@
#include <thread>
#include <thread>
#include <vector>
#include <vector>


#include <android-base/scopeguard.h>
#include <binder/Functional.h>
#include <binder/Parcel.h>
#include <binder/Parcel.h>
#include <binder/RpcServer.h>
#include <binder/RpcServer.h>
#include <binder/RpcTransportRaw.h>
#include <binder/RpcTransportRaw.h>
@@ -45,7 +45,7 @@ namespace android {


constexpr size_t kSessionIdBytes = 32;
constexpr size_t kSessionIdBytes = 32;


using base::ScopeGuard;
using namespace android::binder::impl;
using base::unique_fd;
using base::unique_fd;


RpcServer::RpcServer(std::unique_ptr<RpcTransportCtx> ctx) : mCtx(std::move(ctx)) {}
RpcServer::RpcServer(std::unique_ptr<RpcTransportCtx> ctx) : mCtx(std::move(ctx)) {}
@@ -458,11 +458,12 @@ void RpcServer::establishConnection(
        LOG_ALWAYS_FATAL_IF(threadId == server->mConnectingThreads.end(),
        LOG_ALWAYS_FATAL_IF(threadId == server->mConnectingThreads.end(),
                            "Must establish connection on owned thread");
                            "Must establish connection on owned thread");
        thisThread = std::move(threadId->second);
        thisThread = std::move(threadId->second);
        ScopeGuard detachGuard = [&]() {
        auto detachGuardLambda = [&]() {
            thisThread.detach();
            thisThread.detach();
            _l.unlock();
            _l.unlock();
            server->mShutdownCv.notify_all();
            server->mShutdownCv.notify_all();
        };
        };
        auto detachGuard = make_scope_guard(std::ref(detachGuardLambda));
        server->mConnectingThreads.erase(threadId);
        server->mConnectingThreads.erase(threadId);


        if (status != OK || server->mShutdownTrigger->isTriggered()) {
        if (status != OK || server->mShutdownTrigger->isTriggered()) {
@@ -548,7 +549,7 @@ void RpcServer::establishConnection(
            return;
            return;
        }
        }


        detachGuard.Disable();
        detachGuard.release();
        session->preJoinThreadOwnership(std::move(thisThread));
        session->preJoinThreadOwnership(std::move(thisThread));
    }
    }


Loading