Some code cleanup regarding port allocation

This commit is contained in:
Jordan Dominion
2024-09-15 17:49:59 -04:00
parent b802596375
commit 8e030eda38
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -56,11 +56,11 @@ namespace Tgstation.Server.Tests.Live
public static readonly Version TestUpdateVersion = new(5, 11, 0);
static readonly Lazy<ushort> odDMPort = new(() => FreeTcpPort());
static readonly Lazy<ushort> odDDPort = new(() => FreeTcpPort(odDMPort.Value));
static readonly Lazy<ushort> compatDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value));
static readonly Lazy<ushort> compatDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value));
static readonly Lazy<ushort> mainDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value));
static readonly Lazy<ushort> mainDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value, mainDDPort.Value));
static readonly Lazy<ushort> odDDPort = new(() => FreeTcpPort());
static readonly Lazy<ushort> compatDMPort = new(() => FreeTcpPort());
static readonly Lazy<ushort> compatDDPort = new(() => FreeTcpPort());
static readonly Lazy<ushort> mainDDPort = new(() => FreeTcpPort());
static readonly Lazy<ushort> mainDMPort = new(() => FreeTcpPort());
static void InitializePorts()
{
@@ -157,14 +157,14 @@ namespace Tgstation.Server.Tests.Live
return result;
}
static ushort tcpPortCounter = InitialPort;
static int tcpPortCounter = InitialPort;
static ushort FreeTcpPort(params ushort[] usedPorts)
static ushort FreeTcpPort()
{
ushort result = tcpPortCounter++;
var result = Interlocked.Increment(ref tcpPortCounter);
Console.WriteLine($"Allocated port: {result}");
return result;
return (ushort)result;
}
[ClassInitialize]