Skip to content

Commit

Permalink
Merge pull request #50 from vinser52/fix_unresolved_handle
Browse files Browse the repository at this point in the history
Fix issue with "Destorying an unresolved handle"
  • Loading branch information
vinser52 authored Feb 17, 2022
2 parents 043df5f + c95b2b3 commit 019b2a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cachelib/allocator/Handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ struct ReadHandleImpl {
}
}

protected:
friend class ReadHandleImpl;
// Method used only by ReadHandleImpl ctor
void discard() {
it_.store(nullptr, std::memory_order_relaxed);
}
private:
// we are waiting on Item* to be set to a value. One of the valid values is
// nullptr. So choose something that we dont expect to indicate a ptr
Expand Down Expand Up @@ -475,6 +481,7 @@ struct ReadHandleImpl {
if (it_ && it_->isIncomplete()) {
waitContext_ = std::make_shared<ItemWaitContext>(alloc);
if (!alloc_->addWaitContextForMovingItem(it->getKey(), waitContext_)) {
waitContext_->discard();
waitContext_.reset();
}
}
Expand Down

0 comments on commit 019b2a5

Please sign in to comment.