fix: Fixes race condition with world save snapshot request (#2104)
### Summary * Fixes a race condition where the snapshot path isn't between the request snapshot being set on a background thread, and the main loop consuming that flag. Closes #2102
This commit is contained in:
parent
019672b026
commit
717a1a062e
2 changed files with 7 additions and 1 deletions
|
|
@ -517,10 +517,11 @@ public static class Core
|
||||||
DoKill(_restartOnKill);
|
DoKill(_restartOnKill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is generally called from background threads during Preserialize
|
||||||
internal static void RequestSnapshot(string snapshotPath)
|
internal static void RequestSnapshot(string snapshotPath)
|
||||||
{
|
{
|
||||||
_performSnapshot = true;
|
|
||||||
_snapshotPath = snapshotPath;
|
_snapshotPath = snapshotPath;
|
||||||
|
_performSnapshot = true; // Set this after the path so race conditions do not occur
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void VerifySerialization()
|
public static void VerifySerialization()
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,11 @@ public static class World
|
||||||
{
|
{
|
||||||
_serializationStart = Core.Now;
|
_serializationStart = Core.Now;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(snapshotPath))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Snapshot path cannot be null or empty", nameof(snapshotPath));
|
||||||
|
}
|
||||||
|
|
||||||
Persistence.SerializeAll();
|
Persistence.SerializeAll();
|
||||||
PauseSerializationThreads();
|
PauseSerializationThreads();
|
||||||
EventSink.InvokeWorldSave();
|
EventSink.InvokeWorldSave();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue