Fix the case where we access the memory after cleaning

This commit is contained in:
Chaoguang Lin 2022-03-28 12:19:01 -07:00
parent 4de05a8a8d
commit fd5734c39e
1 changed files with 15 additions and 2 deletions

View File

@ -8707,11 +8707,24 @@ ACTOR Future<Void> singleChangeFeedStreamInternal(KeyRange range,
results->lastReturnedVersion.set(feedReply.mutations.back().version);
}
if (refresh.canBeSet() && !atLatest && feedReply.atLatestVersion) {
if (!refresh.canBeSet()) {
try {
// refresh is set if and only if this actor is cancelled
wait(Future<Void>(Void()));
// Catch any unexpected behavior if the above contract is broken
ASSERT(false);
} catch (Error& e) {
ASSERT(e.code() == error_code_actor_cancelled);
throw;
}
}
if (!atLatest && feedReply.atLatestVersion) {
atLatest = true;
results->notAtLatest.set(0);
}
if (refresh.canBeSet() && feedReply.minStreamVersion > results->storageData[0]->version.get()) {
if (feedReply.minStreamVersion > results->storageData[0]->version.get()) {
results->storageData[0]->version.set(feedReply.minStreamVersion);
}
}