Commit 336b0166 authored by David Benjamin's avatar David Benjamin Committed by Commit Bot

Fix comparator in CacheStorageScheduler

The comparator did not correctly handle the case when left->priority() >
right->priority(). std::make_heap and friends will not work correctly
with a bad comparator and may arbitrarily misbehave.

This was caught by running tests with _LIBCPP_DEBUG=0.

Bug: 923166, 1018920
Change-Id: Ie480f669746566cbe045c539e203b3b89564d267
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1919659
Auto-Submit: David Benjamin <davidben@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Reviewed-by: default avatarBen Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716027}
parent 489eb046
......@@ -47,7 +47,13 @@ bool OpPointerLessThan(const std::unique_ptr<CacheStorageOperation>& left,
//
// Note, there might be a slight mis-ordering when the 64-bit id values
// rollover, but this should not be critical and will happen very rarely.
return left->priority() < right->priority() || left->id() > right->id();
if (left->priority() < right->priority()) {
return true;
}
if (left->priority() > right->priority()) {
return false;
}
return left->id() > right->id();
}
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment