Skip to content

Commit 02eaf3d

Browse files
generatedunixname1395027625275998meta-codesync[bot]
authored andcommitted
Guard waitContext_.reset() on null hot path in ReadHandleImpl destructor
Reviewed By: rlyerly Differential Revision: D109919889 fbshipit-source-id: 6bb36e09e286f5c3d0f7c4c82126f3c5ca5bb47e
1 parent 7ebb949 commit 02eaf3d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cachelib/allocator/Handle.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ struct ReadHandleImpl {
6363

6464
// reset the handle by releasing the item it holds.
6565
void reset() noexcept {
66-
waitContext_.reset();
66+
// Guard the shared_ptr reset: the vast majority of handles point
67+
// directly at a DRAM item and have no wait context, so avoid the
68+
// unconditional shared_ptr swap machinery in that common path.
69+
if (waitContext_) {
70+
waitContext_.reset();
71+
}
6772

6873
if (it_ == nullptr) {
6974
return;

0 commit comments

Comments
 (0)