Skip to content

Commit 1aa8fbb

Browse files
committed
Add synchronous finishing of all pending I/O on shutdown
1 parent c7afea4 commit 1aa8fbb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,18 @@ GMOD_MODULE_OPEN() {
207207
}
208208

209209
GMOD_MODULE_CLOSE() {
210+
for (int tryNum = 0;; tryNum++) {
211+
for (const auto& task : AsyncIO::Tasks) {
212+
g_pFullFileSystem->AsyncFinish(task->handle);
213+
}
214+
215+
Lua::Think(LUA->GetState());
216+
217+
if (tryNum == 10) {
218+
Warning("AsyncIO: Tried synchronously to finish all async IO operations, but there are still %d task pending. Ignoring them.", AsyncIO::Tasks.size());
219+
break;
220+
}
221+
}
222+
210223
return 0;
211224
}

0 commit comments

Comments
 (0)