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

Commit 5ae7d86c authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "libutils: Looper add 'repoll'" into main

parents 56cbad8c 34a09861
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -532,6 +532,30 @@ int Looper::removeFd(int fd) {
    return removeSequenceNumberLocked(it->second);
}

int Looper::repoll(int fd) {
    AutoMutex _l(mLock);
    const auto& it = mSequenceNumberByFd.find(fd);
    if (it == mSequenceNumberByFd.end()) {
        return 0;
    }

    const auto& request_it = mRequests.find(it->second);
    if (request_it == mRequests.end()) {
        return 0;
    }
    const auto& [seq, request] = *request_it;

    LOG_ALWAYS_FATAL_IF(
            fd != request.fd,
            "Looper has inconsistent data structure. When looking up FD %d found FD %d.", fd,
            request_it->second.fd);

    epoll_event eventItem = createEpollEvent(request.getEpollEvents(), seq);
    if (epoll_ctl(mEpollFd.get(), EPOLL_CTL_MOD, fd, &eventItem) == -1) return 0;

    return 1;  // success
}

int Looper::removeSequenceNumberLocked(SequenceNumber seq) {
#if DEBUG_CALLBACKS
    ALOGD("%p ~ removeFd - seq=%" PRIu64, this, seq);
+2953 −614

File changed.

Preview size limit exceeded, changes collapsed.

+2851 −468

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
@@ -344,6 +344,18 @@ public:
     */
    int removeFd(int fd);

    /**
     * Tell the kernel to check for the same events we're already checking for
     * with this FD. This is to be used when there is a kernel driver bug where
     * the kernel does not properly mark itself as having new data available, in
     * order to force "fd_op->poll()" to be called. You probably don't want to
     * use this in general, and you shouldn't use it unless there is a plan to
     * fix the kernel. See also b/296817256.
     *
     * Returns 1 if successfully repolled, 0 if not.
     */
    int repoll(int fd);

    /**
     * Enqueues a message to be processed by the specified handler.
     *