Revert change

This commit is contained in:
Markus Pilman 2021-03-25 14:00:07 -06:00
parent 1385a776da
commit 1033db9fba
1 changed files with 11 additions and 36 deletions

View File

@ -267,27 +267,20 @@ public:
state std::string filename = self->filename; state std::string filename = self->filename;
wait(g_simulator.onMachine(currentProcess)); wait(g_simulator.onMachine(currentProcess));
try { Promise<bool> startSyncPromise = self->startSyncPromise;
Promise<bool> startSyncPromise = self->startSyncPromise; self->startSyncPromise = Promise<bool>();
self->startSyncPromise = Promise<bool>(); startSyncPromise.send(true);
startSyncPromise.send(true);
std::vector<Future<Void>> outstandingModifications; std::vector<Future<Void>> outstandingModifications;
for (auto itr = self->pendingModifications.ranges().begin(); for (auto itr = self->pendingModifications.ranges().begin(); itr != self->pendingModifications.ranges().end();
itr != self->pendingModifications.ranges().end(); ++itr)
++itr) if (itr->value().isValid() && !itr->value().isReady())
if (itr->value().isValid() && !itr->value().isReady()) outstandingModifications.push_back(itr->value());
outstandingModifications.push_back(itr->value());
// Ignore errors here so that all modifications can finish // Ignore errors here so that all modifications can finish
wait(waitForAllReady(outstandingModifications)); wait(waitForAllReady(outstandingModifications));
wait(g_simulator.onProcess(currentProcess, currentTaskID)); wait(g_simulator.onProcess(currentProcess, currentTaskID));
} catch (Error& e) {
state Error err = e;
wait(g_simulator.onProcess(currentProcess, currentTaskID));
throw err;
}
} }
void addref() override { ReferenceCounted<AsyncFileNonDurable>::addref(); } void addref() override { ReferenceCounted<AsyncFileNonDurable>::addref(); }
@ -301,24 +294,6 @@ public:
} else if (isSoleOwner()) { } else if (isSoleOwner()) {
// isSoleOwner is a bit confusing here. What we mean is that the openFiles map is the sole owner. If we // isSoleOwner is a bit confusing here. What we mean is that the openFiles map is the sole owner. If we
// remove the file from the map to make sure it gets closed. // remove the file from the map to make sure it gets closed.
bool hasPendingModifications = false;
for (auto iter = pendingModifications.ranges().begin(); iter != pendingModifications.ranges().end();
++iter) {
if (iter->value().isValid() && !iter->value().isReady()) {
hasPendingModifications = true;
break;
}
}
if (hasPendingModifications) {
// If we still have pending references we won't close the file and instead wait for them. But while we
// wait for those to complete, another actor might open the file. So we call into an actor that will
// hold a refernce until all pending operations are complete. If someone opens this file before this
// completes, nothing will happen. Otherwise we will enter delref again but this time
// hasPendingModifications will evalualte to false.
addref();
waitOnOutstandingModifications(Reference<AsyncFileNonDurable>(this));
return;
}
auto& openFiles = g_simulator.getCurrentProcess()->machine->openFiles; auto& openFiles = g_simulator.getCurrentProcess()->machine->openFiles;
auto iter = openFiles.find(filename); auto iter = openFiles.find(filename);
// the file could've been renamed (DiskQueue does that for example). In that case the file won't be in the // the file could've been renamed (DiskQueue does that for example). In that case the file won't be in the