Skip to content

Commit

Permalink
Fix main server threads being background threads, addresses #813
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Sep 13, 2024
1 parent 8834938 commit b16544a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions MCGalaxy/Commands/building/CmdImageprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ bool DoImage(Player p, Vec3S32[] m, object state, BlockID block) {
Thread thread;
Server.StartThread(out thread, "ImagePrint",
() => DoDrawImage(p, m, (DrawArgs)state));
thread.IsBackground = true;
return false;
}

Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Games/RoundsGame/RoundsGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public virtual void Start(Player p, string map, int rounds) {

Thread thread;
Server.StartThread(out thread, "Game_ " + GameName, RunGame);
thread.IsBackground = true;
}

/// <summary> Attempts to auto start this game with infinite rounds. </summary>
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Levels/Level.Physics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void StartPhysics() {

Server.StartThread(out physThread, "Physics_" + name,
PhysicsLoop);
physThread.IsBackground = true;
physThreadStarted = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Modules/Relay/RelayBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void IOThread() {
void RunAsync() {
Server.StartThread(out worker, RelayName + "_RelayBot",
IOThread);
worker.IsBackground = true;
}

protected abstract void DoConnect();
Expand Down
2 changes: 2 additions & 0 deletions MCGalaxy/Player/Player.Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ public void HandleCommand(string cmd, string args, CommandData data) {

Thread thread;
Server.StartThread(out thread, "CMD_ " + cmd, callback);
thread.IsBackground = true;
} catch (Exception e) {
Logger.LogError(e);
Message("&WCommand failed");
Expand All @@ -584,6 +585,7 @@ public void HandleCommands(List<string> cmds, CommandData data) {
Thread thread;
Server.StartThread(out thread, "CMDS_",
() => UseCommands(commands, messages, data));
thread.IsBackground = true;
} catch (Exception e) {
Logger.LogError(e);
Message("&WCommand failed.");
Expand Down
1 change: 0 additions & 1 deletion MCGalaxy/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ public static void DoGC() {
public static void StartThread(out Thread thread, string name, ThreadStart threadFunc) {
thread = new Thread(threadFunc);

thread.IsBackground = true;
try { thread.Name = name; } catch { }
thread.Start();
}
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/util/Threading/AsyncWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void WakeupWorker() {
public void RunAsync() {
Thread worker;
Server.StartThread(out worker, ThreadName, SendLoop);
worker.IsBackground = true;
}

public void StopAsync() {
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/util/UIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static void HandleCommand(string text) {
Logger.Log(LogType.CommandUsage, "(console): FAILED COMMAND");
}
});
thread.IsBackground = true;
}

public static string Format(string message) {
Expand Down

0 comments on commit b16544a

Please sign in to comment.