From 8e030eda38969ac22cb948bbc48fa08c2cb3b069 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 15 Sep 2024 17:49:59 -0400 Subject: [PATCH] Some code cleanup regarding port allocation --- .../Live/TestLiveServer.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index 597889e131..8576950da5 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -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 odDMPort = new(() => FreeTcpPort()); - static readonly Lazy odDDPort = new(() => FreeTcpPort(odDMPort.Value)); - static readonly Lazy compatDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value)); - static readonly Lazy compatDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value)); - static readonly Lazy mainDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value)); - static readonly Lazy mainDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value, mainDDPort.Value)); + static readonly Lazy odDDPort = new(() => FreeTcpPort()); + static readonly Lazy compatDMPort = new(() => FreeTcpPort()); + static readonly Lazy compatDDPort = new(() => FreeTcpPort()); + static readonly Lazy mainDDPort = new(() => FreeTcpPort()); + static readonly Lazy 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]