Skip to content

Commit 019b2a5

Browse files
authored
Merge pull request #50 from vinser52/fix_unresolved_handle
Fix issue with "Destorying an unresolved handle"
2 parents 043df5f + c95b2b3 commit 019b2a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cachelib/allocator/Handle.h

+7
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ struct ReadHandleImpl {
392392
}
393393
}
394394

395+
protected:
396+
friend class ReadHandleImpl;
397+
// Method used only by ReadHandleImpl ctor
398+
void discard() {
399+
it_.store(nullptr, std::memory_order_relaxed);
400+
}
395401
private:
396402
// we are waiting on Item* to be set to a value. One of the valid values is
397403
// nullptr. So choose something that we dont expect to indicate a ptr
@@ -475,6 +481,7 @@ struct ReadHandleImpl {
475481
if (it_ && it_->isIncomplete()) {
476482
waitContext_ = std::make_shared<ItemWaitContext>(alloc);
477483
if (!alloc_->addWaitContextForMovingItem(it->getKey(), waitContext_)) {
484+
waitContext_->discard();
478485
waitContext_.reset();
479486
}
480487
}

0 commit comments

Comments
 (0)