Merge branch '2.3' into 2.4-pr

This commit is contained in:
RaidMax 2019-09-26 16:11:58 -05:00
commit f7cbf73c44
7 changed files with 41 additions and 12 deletions

View File

@ -1,8 +1,6 @@
using SharedLibraryCore; using SharedLibraryCore;
using SharedLibraryCore.Events; using SharedLibraryCore.Events;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
namespace IW4MAdmin.Application namespace IW4MAdmin.Application
@ -17,6 +15,11 @@ namespace IW4MAdmin.Application
public void AddEvent(GameEvent gameEvent) public void AddEvent(GameEvent gameEvent)
{ {
#if DEBUG
ThreadPool.GetMaxThreads(out int workerThreads, out int n);
ThreadPool.GetAvailableThreads(out int availableThreads, out int m);
gameEvent.Owner.Logger.WriteDebug($"There are {workerThreads - availableThreads} active threading tasks");
#endif
Manager.OnServerEvent?.Invoke(gameEvent.Owner, new GameEventArgs(null, false, gameEvent)); Manager.OnServerEvent?.Invoke(gameEvent.Owner, new GameEventArgs(null, false, gameEvent));
} }
} }

View File

@ -72,7 +72,6 @@ namespace IW4MAdmin.Application.IO
foreach (var ev in events) foreach (var ev in events)
{ {
_server.Manager.GetEventHandler().AddEvent(ev); _server.Manager.GetEventHandler().AddEvent(ev);
await ev.WaitAsync(Utilities.DefaultCommandTimeout, ev.Owner.Manager.CancellationToken);
} }
previousFileSize = fileSize; previousFileSize = fileSize;

View File

@ -648,8 +648,12 @@ namespace IW4MAdmin
// because we don't want to try to fill up a slot that's not empty yet // because we don't want to try to fill up a slot that's not empty yet
waiterList.Add(e); waiterList.Add(e);
} }
// wait for all the disconnect tasks to finish // wait for all the disconnect tasks to finish
await Task.WhenAll(waiterList.Select(e => e.WaitAsync(Utilities.DefaultCommandTimeout, Manager.CancellationToken))); foreach (var waiter in waiterList)
{
waiter.Wait();
}
waiterList.Clear(); waiterList.Clear();
// this are our new connecting clients // this are our new connecting clients
@ -673,7 +677,10 @@ namespace IW4MAdmin
} }
// wait for all the connect tasks to finish // wait for all the connect tasks to finish
await Task.WhenAll(waiterList.Select(e => e.WaitAsync(Utilities.DefaultCommandTimeout, Manager.CancellationToken))); foreach (var waiter in waiterList)
{
waiter.Wait();
}
waiterList.Clear(); waiterList.Clear();
// these are the clients that have updated // these are the clients that have updated
@ -690,7 +697,10 @@ namespace IW4MAdmin
waiterList.Add(e); waiterList.Add(e);
} }
await Task.WhenAll(waiterList.Select(e => e.WaitAsync(Utilities.DefaultCommandTimeout, Manager.CancellationToken))); foreach (var waiter in waiterList)
{
waiter.Wait();
}
if (ConnectionErrors > 0) if (ConnectionErrors > 0)
{ {

View File

@ -54,9 +54,9 @@ namespace IW4MAdmin.Application
} }
} }
async Task Write(string msg, LogType type) void Write(string msg, LogType type)
{ {
await OnLogWriting.WaitAsync(); OnLogWriting.Wait();
string stringType = type.ToString(); string stringType = type.ToString();
msg = msg.StripColors(); msg = msg.StripColors();
@ -74,7 +74,7 @@ namespace IW4MAdmin.Application
#if DEBUG #if DEBUG
// lets keep it simple and dispose of everything quickly as logging wont be that much (relatively) // lets keep it simple and dispose of everything quickly as logging wont be that much (relatively)
Console.WriteLine(LogLine); Console.WriteLine(LogLine);
await File.AppendAllTextAsync(FileName, $"{LogLine}{Environment.NewLine}"); File.AppendAllText(FileName, $"{LogLine}{Environment.NewLine}");
//Debug.WriteLine(msg); //Debug.WriteLine(msg);
#else #else
if (type == LogType.Error || type == LogType.Verbose) if (type == LogType.Error || type == LogType.Verbose)

View File

@ -235,5 +235,11 @@ namespace SharedLibraryCore
return this; return this;
}); });
} }
public GameEvent Wait()
{
OnProcessed.Wait();
return this;
}
} }
} }

View File

@ -146,6 +146,19 @@ namespace SharedLibraryCore.Services
.Where(_client => _client.AliasLinkId == oldAliasLink.AliasLinkId) .Where(_client => _client.AliasLinkId == oldAliasLink.AliasLinkId)
.ForEachAsync(_client => _client.AliasLinkId = newAliasLink.AliasLinkId); .ForEachAsync(_client => _client.AliasLinkId = newAliasLink.AliasLinkId);
// we also need to update all the penalties or they get deleted
// scenario
// link1 joins with ip1
// link2 joins with ip2,
// link2 receives penalty
// link2 joins with ip1
// pre existing link for link2 detected
// link2 is deleted
// link2 penalties are orphaned
await context.Penalties
.Where(_penalty => _penalty.LinkId == oldAliasLink.AliasLinkId)
.ForEachAsync(_penalty => _penalty.LinkId = newAliasLink.AliasLinkId);
entity.AliasLink = newAliasLink; entity.AliasLink = newAliasLink;
entity.AliasLinkId = newAliasLink.AliasLinkId; entity.AliasLinkId = newAliasLink.AliasLinkId;

View File

@ -104,9 +104,7 @@ namespace WebfrontCore.Controllers
public async Task<IActionResult> PrivilegedAsync() public async Task<IActionResult> PrivilegedAsync()
{ {
var admins = (await Manager.GetClientService().GetPrivilegedClients()) var admins = (await Manager.GetClientService().GetPrivilegedClients())
.GroupBy(a => a.AliasLinkId) .OrderBy(_client => _client.Name);
.Select(_client => _client.OrderByDescending(_c => _c.LastConnection).First())
.OrderByDescending(_client => _client.Level);
var adminsDict = new Dictionary<EFClient.Permission, IList<ClientInfo>>(); var adminsDict = new Dictionary<EFClient.Permission, IList<ClientInfo>>();