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

Commit dc0f937d authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Gerrit Code Review
Browse files

Merge changes from topic "revert-2807644-revert-2780893-XRITMVSTFB-ZYEEKMIRIQ" into main

* changes:
  Revert^2 "Use std::function instead of base::function_ref"
  Revert^2 "Use std::unique_ptr instead of ScopeGuard"
parents 6c746778 35804862
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -21,13 +21,15 @@

#include <poll.h>

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

#include "RpcState.h"
#include "Utils.h"

namespace android {

using namespace android::binder::impl;

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

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

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

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

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

namespace android {

using namespace android::binder::impl;

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

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

        rpcFields->mObjectPositions.reserve(otherRpcFields->mObjectPositions.size());
        if (otherRpcFields->mFds != nullptr) {
+4 −2
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@

#include <binder/ProcessState.h>

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

namespace android {

using namespace android::binder::impl;

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

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

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

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

using namespace android::binder::impl;
using android::Parcel;
using android::base::borrowed_fd;
using android::base::unique_fd;
@@ -218,7 +219,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd
        size_t memoryMappedSize = chunkPayloadSize + mmapPayloadStartOffset;
        void* mappedMemory =
                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); });

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

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

constexpr size_t kSessionIdBytes = 32;

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

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

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

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

Loading