From b49592d66625fccc84b9545c611ef3ca7eb4f78e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 29 Apr 2020 17:05:36 -0500 Subject: [PATCH] fix latent issue with password login due to not retreiving password/salt set semaphore count properly for event execution throttling --- Application/GameEventHandler.cs | 43 ++++++++------------- SharedLibraryCore/Services/ClientService.cs | 4 +- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Application/GameEventHandler.cs b/Application/GameEventHandler.cs index 641d1b71e..8a8d25ea4 100644 --- a/Application/GameEventHandler.cs +++ b/Application/GameEventHandler.cs @@ -13,7 +13,6 @@ namespace IW4MAdmin.Application { private const int MAX_CONCURRENT_EVENTS = 10; private readonly ApplicationManager _manager; - private readonly EventProfiler _profiler; private readonly SemaphoreSlim _processingEvents; private static readonly GameEvent.EventType[] overrideEvents = new[] { @@ -26,41 +25,33 @@ namespace IW4MAdmin.Application public GameEventHandler(IManager mgr) { _manager = (ApplicationManager)mgr; - _profiler = new EventProfiler(mgr.GetLogger(0)); - _processingEvents = new SemaphoreSlim(0, MAX_CONCURRENT_EVENTS); + _processingEvents = new SemaphoreSlim(MAX_CONCURRENT_EVENTS, MAX_CONCURRENT_EVENTS); } private Task GameEventHandler_GameEventAdded(object sender, GameEventArgs args) { -#if DEBUG - var start = DateTime.Now; -#endif - return Task.Run(async () => + try { - try - { - // this is not elegant and there's probably a much better way to do it, but it works for now - await _processingEvents.WaitAsync(); - EventApi.OnGameEvent(sender, args); - await _manager.ExecuteEvent(args.Event); -#if DEBUG - _profiler.Profile(start, DateTime.Now, args.Event); -#endif - } + // this is not elegant and there's probably a much better way to do it, but it works for now + _processingEvents.Wait(); + EventApi.OnGameEvent(sender, args); + return _manager.ExecuteEvent(args.Event); + } - catch - { + catch + { - } + } - finally + finally + { + if (_processingEvents.CurrentCount < MAX_CONCURRENT_EVENTS) { - if (_processingEvents.CurrentCount < MAX_CONCURRENT_EVENTS) - { - _processingEvents.Release(); - } + _processingEvents.Release(); } - }); + } + + return Task.CompletedTask; } public void AddEvent(GameEvent gameEvent) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index fbcfe645e..1a6144ac3 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -384,7 +384,9 @@ namespace SharedLibraryCore.Services Masked = _client.Masked, NetworkId = _client.NetworkId, TotalConnectionTime = _client.TotalConnectionTime, - AliasLink = _client.AliasLink + AliasLink = _client.AliasLink, + Password = _client.Password, + PasswordSalt = _client.PasswordSalt }) .FirstOrDefault(c => c.NetworkId == networkId) );