From 8f391c6afbf924e0a420c148711e55b8c5df23d3 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Thu, 28 Jul 2022 14:10:40 +0200 Subject: [PATCH] allow connection when characteridentification is not null but it's the same user --- MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.cs | 6 +++--- MareSynchronosServer/MareSynchronosServer/Program.cs | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.cs index b75267e..b7b74e4 100644 --- a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.cs +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.cs @@ -45,7 +45,7 @@ namespace MareSynchronosServer.Hubs { _logger.LogInformation("Connection from " + userId); var user = (await _dbContext.Users.SingleAsync(u => u.UID == userId)); - if (!string.IsNullOrEmpty(user.CharacterIdentification)) + if (!string.IsNullOrEmpty(user.CharacterIdentification) && characterIdentification != user.CharacterIdentification) { return new ConnectionDto() { @@ -86,6 +86,8 @@ namespace MareSynchronosServer.Hubs public override async Task OnDisconnectedAsync(Exception exception) { + MareMetrics.Connections.Dec(); + var user = await _dbContext.Users.AsNoTracking().SingleOrDefaultAsync(u => u.UID == AuthenticatedUserId); if (user != null && !string.IsNullOrEmpty(user.CharacterIdentification)) { @@ -112,8 +114,6 @@ namespace MareSynchronosServer.Hubs await _dbContext.Users.CountAsync(u => !string.IsNullOrEmpty(u.CharacterIdentification))); } - MareMetrics.Connections.Dec(); - await base.OnDisconnectedAsync(exception); } diff --git a/MareSynchronosServer/MareSynchronosServer/Program.cs b/MareSynchronosServer/MareSynchronosServer/Program.cs index fc2e1c2..00ca479 100644 --- a/MareSynchronosServer/MareSynchronosServer/Program.cs +++ b/MareSynchronosServer/MareSynchronosServer/Program.cs @@ -20,9 +20,6 @@ namespace MareSynchronosServer System.Threading.ThreadPool.GetMaxThreads(out int worker, out int io); Console.WriteLine($"Before: Worker threads {worker}, IO threads {io}"); - System.Threading.ThreadPool.SetMaxThreads(worker, 10000); - System.Threading.ThreadPool.GetMaxThreads(out int workerNew, out int ioNew); - Console.WriteLine($"After: Worker threads {workerNew}, IO threads {ioNew}"); using (var scope = host.Services.CreateScope()) { @@ -41,6 +38,10 @@ namespace MareSynchronosServer context.RemoveRange(looseFiles); context.SaveChanges(); + System.Threading.ThreadPool.SetMaxThreads(worker, context.Users.Count() * 5); + System.Threading.ThreadPool.GetMaxThreads(out int workerNew, out int ioNew); + Console.WriteLine($"After: Worker threads {workerNew}, IO threads {ioNew}"); + MareMetrics.InitializeMetrics(context, services.GetRequiredService()); }