allow connection when characteridentification is not null but it's the same user

This commit is contained in:
Stanley Dimant
2022-07-28 14:10:40 +02:00
parent a44c3c812f
commit 8f391c6afb
2 changed files with 7 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ namespace MareSynchronosServer.Hubs
{ {
_logger.LogInformation("Connection from " + userId); _logger.LogInformation("Connection from " + userId);
var user = (await _dbContext.Users.SingleAsync(u => u.UID == 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() return new ConnectionDto()
{ {
@@ -86,6 +86,8 @@ namespace MareSynchronosServer.Hubs
public override async Task OnDisconnectedAsync(Exception exception) public override async Task OnDisconnectedAsync(Exception exception)
{ {
MareMetrics.Connections.Dec();
var user = await _dbContext.Users.AsNoTracking().SingleOrDefaultAsync(u => u.UID == AuthenticatedUserId); var user = await _dbContext.Users.AsNoTracking().SingleOrDefaultAsync(u => u.UID == AuthenticatedUserId);
if (user != null && !string.IsNullOrEmpty(user.CharacterIdentification)) if (user != null && !string.IsNullOrEmpty(user.CharacterIdentification))
{ {
@@ -112,8 +114,6 @@ namespace MareSynchronosServer.Hubs
await _dbContext.Users.CountAsync(u => !string.IsNullOrEmpty(u.CharacterIdentification))); await _dbContext.Users.CountAsync(u => !string.IsNullOrEmpty(u.CharacterIdentification)));
} }
MareMetrics.Connections.Dec();
await base.OnDisconnectedAsync(exception); await base.OnDisconnectedAsync(exception);
} }

View File

@@ -20,9 +20,6 @@ namespace MareSynchronosServer
System.Threading.ThreadPool.GetMaxThreads(out int worker, out int io); System.Threading.ThreadPool.GetMaxThreads(out int worker, out int io);
Console.WriteLine($"Before: Worker threads {worker}, IO threads {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()) using (var scope = host.Services.CreateScope())
{ {
@@ -41,6 +38,10 @@ namespace MareSynchronosServer
context.RemoveRange(looseFiles); context.RemoveRange(looseFiles);
context.SaveChanges(); 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<IConfiguration>()); MareMetrics.InitializeMetrics(context, services.GetRequiredService<IConfiguration>());
} }