Lock RoomHelper.Rooms properly

This commit is contained in:
jvyden 2022-06-10 02:42:38 -04:00
parent 02abb7bcab
commit 615b57122e
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 5 additions and 3 deletions

View file

@ -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
}

View file

@ -115,6 +115,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=dpadrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ezoiar/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=farc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLUSHALL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=friendscores/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ingame/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kettu/@EntryIndexedValue">True</s:Boolean>

View file

@ -16,6 +16,7 @@ namespace LBPUnion.ProjectLighthouse.Match.Rooms;
public class RoomHelper
{
public static readonly object RoomLock = new();
public static StorableList<Room> 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();