From 3ccc23f23d8604674690db1996c0922e2e255180 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 11 Jul 2025 17:48:44 -0500 Subject: prevent throwing during finalization --- src/slskd/Core/ConnectionWatchdog.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Core/ConnectionWatchdog.cs b/src/slskd/Core/ConnectionWatchdog.cs index 9964514b..5001f024 100644 --- a/src/slskd/Core/ConnectionWatchdog.cs +++ b/src/slskd/Core/ConnectionWatchdog.cs @@ -233,7 +233,18 @@ namespace slskd } finally { - CancellationTokenSource?.Dispose(); + var cts = CancellationTokenSource; + CancellationTokenSource = null; + + try + { + cts?.Dispose(); + } + catch (Exception) + { + // noop. i don't think this can throw, but if we fail to release the SyncRoot we'll be in trouble. + } + SyncRoot.Release(); } } -- cgit v1.2.3