From bf23f03b9118a1eb895e017ac3f9cc072f74f0e9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 22 Oct 2023 09:17:34 -0400 Subject: [PATCH] Fix DMAPI post validate timeout applying to all sessions --- .../Components/Session/SessionController.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 4672b63757..8e8a4715ec 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -167,6 +167,11 @@ namespace Tgstation.Server.Host.Components.Session /// readonly object synchronizationLock; + /// + /// If this session is meant to validate the presence of the DMAPI. + /// + readonly bool apiValidationSession; + /// /// The waits on when DreamDaemon currently has it's ports closed. /// @@ -244,7 +249,7 @@ namespace Tgstation.Server.Host.Components.Session /// The returning a to be run after the ends. /// The optional time to wait before failing the . /// If this is a reattached session. - /// If this is a DMAPI validation session. + /// The value of . public SessionController( ReattachInformation reattachInformation, Api.Models.Instance metadata, @@ -276,6 +281,8 @@ namespace Tgstation.Server.Host.Components.Session this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); + apiValidationSession = apiValidate; + portClosedForReboot = false; disposed = false; apiValidationStatus = ApiValidationStatus.NeverValidated; @@ -296,7 +303,7 @@ namespace Tgstation.Server.Host.Components.Session topicSendSemaphore = new FifoSemaphore(); synchronizationLock = new object(); - if (apiValidate || DMApiAvailable) + if (apiValidationSession || DMApiAvailable) { bridgeRegistration = bridgeRegistrar.RegisterHandler(this); this.chatTrackingContext.SetChannelSink(this); @@ -775,9 +782,16 @@ namespace Tgstation.Server.Host.Components.Session break; case BridgeCommandType.Startup: - var proceedTcs = new TaskCompletionSource(); - var firstValidationRequest = Interlocked.CompareExchange(ref postValidationShutdownTask, PostValidationShutdown(proceedTcs.Task), null) == null; - proceedTcs.SetResult(firstValidationRequest); + bool firstValidationRequest; + if (apiValidationSession) + { + var proceedTcs = new TaskCompletionSource(); + firstValidationRequest = Interlocked.CompareExchange(ref postValidationShutdownTask, PostValidationShutdown(proceedTcs.Task), null) == null; + proceedTcs.SetResult(firstValidationRequest); + } + else + firstValidationRequest = Interlocked.CompareExchange(ref postValidationShutdownTask, Task.CompletedTask, null) == null; + apiValidationStatus = ApiValidationStatus.BadValidationRequest; if (!firstValidationRequest)