diff --git a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs
index a2bff1e0..7039a9bf 100644
--- a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs
+++ b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs
@@ -42,7 +42,7 @@ public class RoomVisualizerController : ControllerBase
#if !DEBUG
return this.NotFound();
#else
- RoomHelper.Rooms.RemoveAll();
+ lock(RoomHelper.RoomLock) RoomHelper.Rooms.RemoveAll();
return this.Redirect("/debug/roomVisualizer");
#endif
}
diff --git a/ProjectLighthouse.sln.DotSettings b/ProjectLighthouse.sln.DotSettings
index 8a9a5b94..524940d2 100644
--- a/ProjectLighthouse.sln.DotSettings
+++ b/ProjectLighthouse.sln.DotSettings
@@ -115,6 +115,7 @@
True
True
True
+ True
True
True
True
diff --git a/ProjectLighthouse/Match/Rooms/RoomHelper.cs b/ProjectLighthouse/Match/Rooms/RoomHelper.cs
index 4e09d5ea..33f1959c 100644
--- a/ProjectLighthouse/Match/Rooms/RoomHelper.cs
+++ b/ProjectLighthouse/Match/Rooms/RoomHelper.cs
@@ -16,6 +16,7 @@ namespace LBPUnion.ProjectLighthouse.Match.Rooms;
public class RoomHelper
{
+ public static readonly object RoomLock = new();
public static StorableList Rooms => RoomStore.GetRooms();
public static void StartCleanupThread()
@@ -162,7 +163,7 @@ public class RoomHelper
};
CleanupRooms(room.HostId, room);
- lock(Rooms) Rooms.Add(room);
+ lock(RoomLock) Rooms.Add(room);
Logger.Info($"Created room (id: {room.RoomId}) for host {room.HostId}", LogArea.Match);
return room;
@@ -193,7 +194,7 @@ public class RoomHelper
[SuppressMessage("ReSharper", "InvertIf")]
public static void CleanupRooms(int? hostId = null, Room? newRoom = null, Database? database = null)
{
- lock(Rooms)
+ lock(RoomLock)
{
int roomCountBeforeCleanup = Rooms.Count();