mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-20 04:22:51 +01:00
Some code cleanup regarding port allocation
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user