@@ -1271,35 +1271,17 @@ CacheAllocator<CacheTrait>::moveRegularItemOnEviction(
1271
1271
// make sure that no other thread removed it, and only then replaces it.
1272
1272
if (!replaceInMMContainer (oldItemPtr, *newItemHdl)) {
1273
1273
accessContainer_->remove (*newItemHdl);
1274
- return {} ;
1274
+ return acquire (&oldItem) ;
1275
1275
}
1276
1276
1277
1277
// Replacing into the MM container was successful, but someone could have
1278
1278
// called insertOrReplace() or remove() before or after the
1279
1279
// replaceInMMContainer() operation, which would invalidate newItemHdl.
1280
1280
if (!newItemHdl->isAccessible ()) {
1281
1281
removeFromMMContainer (*newItemHdl);
1282
- return {} ;
1282
+ return acquire (&oldItem) ;
1283
1283
}
1284
1284
1285
- // no one can add or remove chained items at this point
1286
- if (oldItem.hasChainedItem ()) {
1287
- // safe to acquire handle for a moving Item
1288
- auto oldHandle = acquire (&oldItem);
1289
- XDCHECK_EQ (1u , oldHandle->getRefCount ()) << oldHandle->toString ();
1290
- XDCHECK (!newItemHdl->hasChainedItem ()) << newItemHdl->toString ();
1291
- try {
1292
- auto l = chainedItemLocks_.lockExclusive (oldItem.getKey ());
1293
- transferChainLocked (oldHandle, newItemHdl);
1294
- } catch (const std::exception& e) {
1295
- // this should never happen because we drained all the handles.
1296
- XLOGF (DFATAL, " {}" , e.what ());
1297
- throw ;
1298
- }
1299
-
1300
- XDCHECK (!oldItem.hasChainedItem ());
1301
- XDCHECK (newItemHdl->hasChainedItem ());
1302
- }
1303
1285
newItemHdl.unmarkNascent ();
1304
1286
resHdl = std::move (newItemHdl); // guard will assign it to ctx under lock
1305
1287
return acquire (&oldItem);
0 commit comments