From d7617d461cb14eb593641df023c79634befab1c2 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 20 Dec 2021 17:29:32 -0600 Subject: use a semaphore for options sync --- src/slskd/Application.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 6ce17bf5..d6ae4744 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -128,7 +128,7 @@ namespace slskd private Options Options => OptionsMonitor.CurrentValue; private OptionsAtStartup OptionsAtStartup { get; set; } private IOptionsMonitor OptionsMonitor { get; set; } - private ReaderWriterLockSlim OptionsSyncRoot { get; } = new ReaderWriterLockSlim(); + private SemaphoreSlim OptionsSyncRoot { get; } = new SemaphoreSlim(1, 1); private Options PreviousOptions { get; set; } private IPushbulletService Pushbullet { get; } private ISharedFileCache SharedFileCache { get; set; } @@ -565,7 +565,7 @@ namespace slskd // this code is known to fire more than once per update. i'm not sure whether these might be executed concurrently. // lock to be safe, because we need to accurately track the last value of Options for diffing purposes. threading // shenanigans here could lead to missed updates. - OptionsSyncRoot.EnterWriteLock(); + await OptionsSyncRoot.WaitAsync(); try { @@ -713,7 +713,7 @@ namespace slskd } finally { - OptionsSyncRoot.ExitWriteLock(); + OptionsSyncRoot.Release(); } } -- cgit v1.2.3