1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

Fix small issue with saving client kills multithreaded

This commit is contained in:
RaidMax
2019-08-23 19:11:36 -05:00
parent abec466f3f
commit 09061a310b

View File

@ -556,18 +556,21 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
if (Plugin.Config.Configuration().StoreClientKills)
{
_hitCache.Add(hit);
if (_hitCache.Count > Detection.MAX_TRACKED_HIT_COUNT)
lock (_hitCache)
{
_hitCache.Add(hit);
using (var ctx = new DatabaseContext())
if (_hitCache.Count > Detection.MAX_TRACKED_HIT_COUNT)
{
ctx.AddRange(_hitCache);
await ctx.SaveChangesAsync();
}
_hitCache.Clear();
using (var ctx = new DatabaseContext())
{
ctx.AddRange(_hitCache);
await ctx.SaveChangesAsync();
}
_hitCache.Clear();
}
}
}
@ -578,7 +581,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
#if DEBUG
if (clientDetection.TrackedHits.Count > 0)
#else
if (clientDetection.TrackedHits.Count > Detection.MAX_TRACKED_HIT_COUNT)
if (clientDetection.TrackedHits.Count > Detection.MAX_TRACKED_HIT_COUNT)
#endif
{
while (clientDetection.TrackedHits.Count > 0)