From 994610869dd81b9c9fd30d6dc28cb0d5013843cb Mon Sep 17 00:00:00 2001 From: Maplewheels Date: Sat, 21 Mar 2026 23:59:19 -0400 Subject: [PATCH] Fixed deadlock scenario caused by unsubscribing during an event. --- .../SharedSource/LuaCs/_Services/EventService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs index d12f4f545..9971b369a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs @@ -264,7 +264,7 @@ public partial class EventService : IEventService public void Unsubscribe(T subscriber) where T : class, IEvent { Guard.IsNotNull(subscriber, nameof(subscriber)); - using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult(); + using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult(); IService.CheckDisposed(this); if (!_subscribers.TryGetValue(typeof(T), out var evtSubscribers))