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

Commit 331ad6e8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "BufferPool: Guarantee double-loadability" into rvc-dev am: 241746e7...

Merge "BufferPool: Guarantee double-loadability" into rvc-dev am: 241746e7 am: b54e5739 am: 0590200e

Change-Id: I6704ba59c70699b2d8f88fdc105168973cf2710c
parents 818f4412 0590200e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -135,7 +135,14 @@ bool contains(std::map<T, std::set<U>> *mapOfSet, T key, U value) {
    return false;
}

uint32_t Accessor::Impl::sSeqId = time(nullptr);
#ifdef __ANDROID_VNDK__
static constexpr uint32_t kSeqIdVndkBit = 1 << 31;
#else
static constexpr uint32_t kSeqIdVndkBit = 0;
#endif

static constexpr uint32_t kSeqIdMax = 0x7fffffff;
uint32_t Accessor::Impl::sSeqId = time(nullptr) & kSeqIdMax;

Accessor::Impl::Impl(
        const std::shared_ptr<BufferPoolAllocator> &allocator)
@@ -157,7 +164,7 @@ ResultStatus Accessor::Impl::connect(
        std::lock_guard<std::mutex> lock(mBufferPool.mMutex);
        if (newConnection) {
            int32_t pid = getpid();
            ConnectionId id = (int64_t)pid << 32 | sSeqId;
            ConnectionId id = (int64_t)pid << 32 | sSeqId | kSeqIdVndkBit;
            status = mBufferPool.mObserver.open(id, statusDescPtr);
            if (status == ResultStatus::OK) {
                newConnection->initialize(accessor, id);
@@ -167,7 +174,7 @@ ResultStatus Accessor::Impl::connect(
                mBufferPool.mConnectionIds.insert(id);
                mBufferPool.mInvalidationChannel.getDesc(invDescPtr);
                mBufferPool.mInvalidation.onConnect(id, observer);
                if (sSeqId == UINT32_MAX) {
                if (sSeqId == kSeqIdMax) {
                   sSeqId = 0;
                } else {
                    ++sSeqId;