From b70b6bf3265263787840eff01f74524336dca5c1 Mon Sep 17 00:00:00 2001 From: MapleWheels Date: Tue, 24 Mar 2026 02:44:08 -0400 Subject: [PATCH] Fixed deadlock scenario in the event dispatcher CRUD API. --- .../SharedSource/LuaCs/_Services/EventService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs index 862f507c6..34102b8cc 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs @@ -280,7 +280,7 @@ public partial class EventService : IEventService public void ClearAllEventSubscribers() where T : class, IEvent { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribers.TryRemove(typeof(T), out _); } @@ -329,7 +329,7 @@ public partial class EventService : IEventService public void AddDispatcherEventService(IEventService eventService) { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribedEventDispatchers.TryAdd(eventService, eventService); @@ -337,7 +337,7 @@ public partial class EventService : IEventService public void RemoveDispatcherEventService(IEventService eventService) { - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); _subscribedEventDispatchers.TryRemove(eventService, out _);