return nullptr;
}
+ // store hadWriter before checking ENTRY_REQUIRES_COLLAPSING to avoid racing
+ // the writer that clears that flag and then leaves
+ const auto hadWriter = map->peekAtWriter(index);
+ if (!hadWriter && EBIT_TEST(anchor->basics.flags, ENTRY_REQUIRES_COLLAPSING)) {
+ debugs(20, 3, "not joining abandoned entry " << index);
+ map->closeForReadingAndFreeIdle(index);
+ return nullptr;
+ }
+
StoreEntry *e = new StoreEntry();
e->createMemObject();
e->mem_obj->xitTable.index = index;
e->mem_obj->xitTable.io = Store::ioReading;
anchor->exportInto(*e);
- const bool collapsingRequired = EBIT_TEST(anchor->basics.flags, ENTRY_REQUIRES_COLLAPSING);
- e->setCollapsingRequirement(collapsingRequired);
+
+ if (EBIT_TEST(anchor->basics.flags, ENTRY_REQUIRES_COLLAPSING)) {
+ assert(hadWriter);
+ e->setCollapsingRequirement(true);
+ }
+
// keep read lock to receive updates from others
return e;
}