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

Commit 84b7cff1 authored by Sebastian Pickl's avatar Sebastian Pickl
Browse files

Revert "Use std::function instead of base::function_ref"

Revert submission 2780893

Reason for revert: breaking boot tests

Bug: 308214260

Reverted changes: /q/submissionid:2780893

Change-Id: Ibbd9bf2c9eb1389c9b8217cc75a98a3ec13b77d8
parent 9636af27
Loading
Loading
Loading
Loading
+18 −17
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ RpcState::CommandData::CommandData(size_t size) : mSize(size) {
status_t RpcState::rpcSend(
        const sp<RpcSession::RpcConnection>& connection, const sp<RpcSession>& session,
        const char* what, iovec* iovs, int niovs,
        const std::optional<SmallFunction<status_t()>>& altPoll,
        const std::optional<android::base::function_ref<status_t()>>& altPoll,
        const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds) {
    for (int i = 0; i < niovs; i++) {
        LOG_RPC_DETAIL("Sending %s (part %d of %d) on RpcTransport %p: %s",
@@ -604,7 +604,9 @@ status_t RpcState::transactAddress(const sp<RpcSession::RpcConnection>& connecti
            {const_cast<uint8_t*>(data.data()), data.dataSize()},
            objectTableSpan.toIovec(),
    };
    auto altPoll = [&] {
    if (status_t status = rpcSend(
                connection, session, "transaction", iovs, arraysize(iovs),
                [&] {
                    if (waitUs > kWaitLogUs) {
                        ALOGE("Cannot send command, trying to process pending refcounts. Waiting "
                              "%zuus. Too many oneway calls?",
@@ -619,9 +621,8 @@ status_t RpcState::transactAddress(const sp<RpcSession::RpcConnection>& connecti
                    }

                    return drainCommands(connection, session, CommandType::CONTROL_ONLY);
    };
    if (status_t status = rpcSend(connection, session, "transaction", iovs, arraysize(iovs),
                                  std::ref(altPoll), rpcFields->mFds.get());
                },
                rpcFields->mFds.get());
        status != OK) {
        // rpcSend calls shutdownAndWait, so all refcounts should be reset. If we ever tolerate
        // errors here, then we may need to undo the binder-sent counts for the transaction as
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#pragma once

#include <android-base/unique_fd.h>
#include <binder/Functional.h>
#include <binder/IBinder.h>
#include <binder/Parcel.h>
#include <binder/RpcSession.h>
@@ -191,7 +190,7 @@ private:
    [[nodiscard]] status_t rpcSend(
            const sp<RpcSession::RpcConnection>& connection, const sp<RpcSession>& session,
            const char* what, iovec* iovs, int niovs,
            const std::optional<binder::impl::SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds =
                    nullptr);
    [[nodiscard]] status_t rpcRec(
+2 −4
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@

namespace android {

using namespace android::binder::impl;

// RpcTransport with TLS disabled.
class RpcTransportRaw : public RpcTransport {
public:
@@ -56,7 +54,7 @@ public:

    status_t interruptableWriteFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds)
            override {
        bool sentFds = false;
@@ -72,7 +70,7 @@ public:

    status_t interruptableReadFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds) override {
        auto recv = [&](iovec* iovs, int niovs) -> ssize_t {
            return binder::os::receiveMessageFromSocket(mSocket, iovs, niovs, ancillaryFds);
+2 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include "RpcState.h"
#include "RpcTransportUtils.h"

using namespace android::binder::impl;
using android::base::Error;
using android::base::Result;

@@ -76,7 +75,7 @@ public:

    status_t interruptableWriteFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds)
            override {
        auto writeFn = [&](iovec* iovs, size_t niovs) -> ssize_t {
@@ -94,7 +93,7 @@ public:

    status_t interruptableReadFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* /*ancillaryFds*/)
            override {
        auto readFn = [&](iovec* iovs, size_t niovs) -> ssize_t {
+9 −11
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@
#endif

namespace android {

using namespace android::binder::impl;

namespace {

// Implement BIO for socket that ignores SIGPIPE.
@@ -184,9 +181,10 @@ public:
    // |sslError| should be from Ssl::getError().
    // If |sslError| is WANT_READ / WANT_WRITE, poll for POLLIN / POLLOUT respectively. Otherwise
    // return error. Also return error if |fdTrigger| is triggered before or during poll().
    status_t pollForSslError(const android::RpcTransportFd& fd, int sslError, FdTrigger* fdTrigger,
    status_t pollForSslError(
            const android::RpcTransportFd& fd, int sslError, FdTrigger* fdTrigger,
            const char* fnString, int additionalEvent,
                             const std::optional<SmallFunction<status_t()>>& altPoll) {
            const std::optional<android::base::function_ref<status_t()>>& altPoll) {
        switch (sslError) {
            case SSL_ERROR_WANT_READ:
                return handlePoll(POLLIN | additionalEvent, fd, fdTrigger, fnString, altPoll);
@@ -202,7 +200,7 @@ private:

    status_t handlePoll(int event, const android::RpcTransportFd& fd, FdTrigger* fdTrigger,
                        const char* fnString,
                        const std::optional<SmallFunction<status_t()>>& altPoll) {
                        const std::optional<android::base::function_ref<status_t()>>& altPoll) {
        status_t ret;
        if (altPoll) {
            ret = (*altPoll)();
@@ -286,12 +284,12 @@ public:
    status_t pollRead(void) override;
    status_t interruptableWriteFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds)
            override;
    status_t interruptableReadFully(
            FdTrigger* fdTrigger, iovec* iovs, int niovs,
            const std::optional<SmallFunction<status_t()>>& altPoll,
            const std::optional<android::base::function_ref<status_t()>>& altPoll,
            std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds) override;

    bool isWaiting() override { return mSocket.isInPollingState(); };
@@ -322,7 +320,7 @@ status_t RpcTransportTls::pollRead(void) {

status_t RpcTransportTls::interruptableWriteFully(
        FdTrigger* fdTrigger, iovec* iovs, int niovs,
        const std::optional<SmallFunction<status_t()>>& altPoll,
        const std::optional<android::base::function_ref<status_t()>>& altPoll,
        const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds) {
    (void)ancillaryFds;

@@ -368,7 +366,7 @@ status_t RpcTransportTls::interruptableWriteFully(

status_t RpcTransportTls::interruptableReadFully(
        FdTrigger* fdTrigger, iovec* iovs, int niovs,
        const std::optional<SmallFunction<status_t()>>& altPoll,
        const std::optional<android::base::function_ref<status_t()>>& altPoll,
        std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds) {
    (void)ancillaryFds;

Loading