diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-20 17:29:32 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-20 17:29:32 -0600 |
| commit | d7617d461cb14eb593641df023c79634befab1c2 (patch) | |
| tree | bc1c775d54f08d41466b6c48eec2abeaa50bd1a3 /src | |
| parent | efed2c34a9266a58e8b729d60b0ae55278a7f779 (diff) | |
| download | slskd-d7617d461cb14eb593641df023c79634befab1c2.tar.gz | |
use a semaphore for options sync
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 6 |
1 files changed, 3 insertions, 3 deletions
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<Options> 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(); } } |
