fix latent issue with password login due to not retreiving password/salt

set semaphore count properly for event execution throttling
This commit is contained in:
RaidMax 2020-04-29 17:05:36 -05:00
parent c82139b88c
commit b49592d666
2 changed files with 20 additions and 27 deletions

View File

@ -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,26 +25,17 @@ 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
{
// this is not elegant and there's probably a much better way to do it, but it works for now
await _processingEvents.WaitAsync();
_processingEvents.Wait();
EventApi.OnGameEvent(sender, args);
await _manager.ExecuteEvent(args.Event);
#if DEBUG
_profiler.Profile(start, DateTime.Now, args.Event);
#endif
return _manager.ExecuteEvent(args.Event);
}
catch
@ -60,7 +50,8 @@ namespace IW4MAdmin.Application
_processingEvents.Release();
}
}
});
return Task.CompletedTask;
}
public void AddEvent(GameEvent gameEvent)

View File

@ -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)
);