Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Moves snapshot request synchronously #2105

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Projects/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@

last = now;

if (idleCPU && cyclesPerSecond > 125)

Check warning on line 504 in Projects/Server/Main.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant operand in logical conditional expression

Redundant operand in logical conditional expression
{
Thread.Sleep(2);
}
Expand All @@ -517,11 +517,10 @@
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 Expand Up @@ -563,7 +562,7 @@
try
{
if (World.DirtyTrackingEnabled)
{

Check warning on line 565 in Projects/Server/Main.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Heuristically unreachable code

Code is heuristically unreachable
var manualDirtyCheckingAttribute = type.GetCustomAttribute<ManualDirtyCheckingAttribute>(false);
var codeGennedAttribute = type.GetCustomAttribute<ModernUO.Serialization.SerializationGeneratorAttribute>(false);

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
Loading