diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-10-12 08:36:24 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-10-12 08:36:24 -0500 |
| commit | 2972827f496202a6355b9be0437e323bd739aa4e (patch) | |
| tree | b6fa8306b4ee483f6f3aa26bd8e612a47f67afd1 /src/slskd/Program.cs | |
| parent | 1f25a5c3cb1a8a212d13292beec7124966606a63 (diff) | |
| download | slskd-2972827f496202a6355b9be0437e323bd739aa4e.tar.gz | |
fix warnings
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 56ab6317..8b816f48 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -32,8 +32,6 @@ namespace slskd using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; - using System.Threading; - using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; @@ -262,29 +260,36 @@ namespace slskd return; } + var reqInitialOwnership = false; - using(var mutex = new Mutex(reqInitialOwnership, AppName)) + + using (var mutex = new Mutex(reqInitialOwnership, AppName)) { var hasHandle = false; - try{ - try{ - if(!mutex.WaitOne(0, false)){ - Console.WriteLine("Another instance of this program is running"); - Environment.Exit(0); - } + try + { + try + { + if (!mutex.WaitOne(0, false)) + { + Console.WriteLine("Another instance of this program is running"); + Environment.Exit(0); + } } catch (AbandonedMutexException) { - hasHandle=true; + hasHandle = true; } } finally { - if(hasHandle) + if (hasHandle) + { mutex.ReleaseMutex(); + } } - } - + } + if (GenerateCertificate) { GenerateX509Certificate(password: Cryptography.Random.GetBytes(16).ToBase62String(), filename: $"{AppName}.pfx"); |
