Skip to content

Commit 752971c

Browse files
igchorbyrnedj
authored andcommitted
Insert the child to MMContainer after incrementing
the ref count. This is to avoid incRef failing in case the item is selected for eviction/slab release.
1 parent d2cbd5b commit 752971c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cachelib/allocator/CacheAllocator-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,15 @@ void CacheAllocator<CacheTrait>::addChainedItem(WriteHandle& parent,
544544
// Count a new child
545545
stats_.numChainedChildItems.inc();
546546

547-
insertInMMContainer(*child);
548-
549547
// Increment refcount since this chained item is now owned by the parent
550548
// Parent will decrement the refcount upon release. Since this is an
551549
// internal refcount, we dont include it in active handle tracking.
552550
auto ret = child->incRef(true);
553551
XDCHECK(ret == RefcountWithFlags::incResult::incOk);
554552
XDCHECK_EQ(2u, child->getRefCount());
555553

554+
insertInMMContainer(*child);
555+
556556
invalidateNvm(*parent);
557557
if (auto eventTracker = getEventTracker()) {
558558
eventTracker->record(AllocatorApiEvent::ADD_CHAINED, parent->getKey(),

0 commit comments

Comments
 (0)