Avoid passing references from an iterator into an insertion that invalidates the iterator.
This commit is contained in:
parent
cd977cf49e
commit
2b4ec39a2f
|
@ -577,13 +577,6 @@ ACTOR Future<Void> updateCachedRanges(DatabaseContext* self, std::map<UID, Stora
|
|||
containedRangesBegin = ranges.begin().range().begin;
|
||||
}
|
||||
for (auto iter = ranges.begin(); iter != ranges.end(); ++iter) {
|
||||
// We probably don't want to do the code below? Otherwise we would never
|
||||
// fetch the corresponding storages - which would give us a different semantics
|
||||
//if (containedRangesEnd > iter->range().begin) {
|
||||
// self->locationCache.insert(
|
||||
// KeyRangeRef{ containedRangesEnd, iter->range().begin },
|
||||
// Reference<LocationInfo>{ new LocationInfo{ cacheInterfaces, true } });
|
||||
//}
|
||||
containedRangesEnd = iter->range().end;
|
||||
if (iter->value() && !iter->value()->hasCaches) {
|
||||
iter->value() = addCaches(iter->value(), cacheInterfaces);
|
||||
|
@ -592,7 +585,8 @@ ACTOR Future<Void> updateCachedRanges(DatabaseContext* self, std::map<UID, Stora
|
|||
auto iter = self->locationCache.rangeContaining(begin);
|
||||
if (iter->value() && !iter->value()->hasCaches) {
|
||||
if (end>=iter->range().end) {
|
||||
self->locationCache.insert(KeyRangeRef{ begin, iter->range().end },
|
||||
Key endCopy = iter->range().end; // Copy because insertion invalidates iterator
|
||||
self->locationCache.insert(KeyRangeRef{ begin, endCopy },
|
||||
addCaches(iter->value(), cacheInterfaces));
|
||||
} else {
|
||||
self->locationCache.insert(KeyRangeRef{ begin, end },
|
||||
|
@ -601,7 +595,8 @@ ACTOR Future<Void> updateCachedRanges(DatabaseContext* self, std::map<UID, Stora
|
|||
}
|
||||
iter = self->locationCache.rangeContainingKeyBefore(end);
|
||||
if (iter->value() && !iter->value()->hasCaches) {
|
||||
self->locationCache.insert(KeyRangeRef{iter->range().begin, end}, addCaches(iter->value(), cacheInterfaces));
|
||||
Key beginCopy = iter->range().begin; // Copy because insertion invalidates iterator
|
||||
self->locationCache.insert(KeyRangeRef{beginCopy, end}, addCaches(iter->value(), cacheInterfaces));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue