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

Commit 00d2fb6e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Assure pending invalidations are processed"

parents 6fdd7d07 b355f7cf
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -308,7 +308,11 @@ void Accessor::Impl::BufferPool::Invalidation::onAck(
        ConnectionId conId,
        uint32_t msgId) {
    auto it = mAcks.find(conId);
    if (it == mAcks.end() || isMessageLater(msgId, it->second)) {
    if (it == mAcks.end()) {
        ALOGW("ACK from inconsistent connection! %lld", (long long)conId);
        return;
    }
    if (isMessageLater(msgId, it->second)) {
        mAcks[conId] = msgId;
    }
}
@@ -327,7 +331,6 @@ void Accessor::Impl::BufferPool::Invalidation::onBufferInvalidated(
                }
            }
            channel.postInvalidation(msgId, it->mFrom, it->mTo);
            sInvalidator->addAccessor(mId, it->mImpl);
            it = mPendings.erase(it);
            continue;
        }
@@ -342,7 +345,6 @@ void Accessor::Impl::BufferPool::Invalidation::onInvalidationRequest(
        size_t left,
        BufferInvalidationChannel &channel,
        const std::shared_ptr<Accessor::Impl> &impl) {
    if (left == 0) {
        uint32_t msgId = 0;
    if (needsAck) {
        msgId = ++mInvalidationId;
@@ -352,14 +354,15 @@ void Accessor::Impl::BufferPool::Invalidation::onInvalidationRequest(
        }
    }
    ALOGV("bufferpool invalidation requested and queued");
    if (left == 0) {
        channel.postInvalidation(msgId, from, to);
        sInvalidator->addAccessor(mId, impl);
    } else {
        // TODO: sending hint message?
        ALOGV("bufferpool invalidation requested and pending");
        Pending pending(needsAck, from, to, left, impl);
        mPendings.push_back(pending);
    }
    sInvalidator->addAccessor(mId, impl);
}

void Accessor::Impl::BufferPool::Invalidation::onHandleAck() {
@@ -373,6 +376,9 @@ void Accessor::Impl::BufferPool::Invalidation::onHandleAck() {
                          (long long)it->first, it->second, mInvalidationId);
                    Return<void> transResult = observer->onMessage(it->first, mInvalidationId);
                    (void) transResult;
                    // N.B: ignore possibility of onMessage oneway call being
                    // lost.
                    it->second = mInvalidationId;
                } else {
                    ALOGV("bufferpool observer died %lld", (long long)it->first);
                    deads.insert(it->first);
@@ -385,9 +391,11 @@ void Accessor::Impl::BufferPool::Invalidation::onHandleAck() {
            }
        }
    }
    // All invalidation Ids are synced.
    if (mPendings.size() == 0) {
        // All invalidation Ids are synced and no more pending invalidations.
        sInvalidator->delAccessor(mId);
    }
}

bool Accessor::Impl::BufferPool::handleOwnBuffer(
        ConnectionId connectionId, BufferId bufferId) {