Skip to content

Commit

Permalink
fix: Moves snapshot request synchronously (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Feb 2, 2025
1 parent 717a1a0 commit e64a632
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Projects/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,10 @@ public static void RunEventLoop()
DoKill(_restartOnKill);
}

// This is generally called from background threads during Preserialize
internal static void RequestSnapshot(string snapshotPath)
{
_snapshotPath = snapshotPath;
_performSnapshot = true; // Set this after the path so race conditions do not occur
_performSnapshot = true;
}

public static void VerifySerialization()
Expand Down
6 changes: 3 additions & 3 deletions Projects/Server/World/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ public static void Save()

private static void Preserialize(object state)
{
var tempPath = PathUtility.EnsureRandomPath(_tempSavePath);

try
{
// Allocate the heaps for the GC
Expand All @@ -290,7 +288,9 @@ private static void Preserialize(object state)
}

WakeSerializationThreads();
Core.RequestSnapshot(tempPath);

// Execute this synchronously so we don't have a race condition
Core.LoopContext.Post(() => Core.RequestSnapshot(PathUtility.EnsureRandomPath(_tempSavePath)));
}
catch (Exception ex)
{
Expand Down

0 comments on commit e64a632

Please sign in to comment.