Fix restarts triggering when the same launch parameters are reloaded

This commit is contained in:
Cyberboss
2018-09-20 10:45:53 -04:00
parent 2588d78a3d
commit b37ddfe1bc
2 changed files with 17 additions and 1 deletions
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models.Internal
{
@@ -36,5 +37,17 @@ namespace Tgstation.Server.Api.Models.Internal
/// </summary>
[Required]
public uint? StartupTimeout { get; set; }
/// <summary>
/// Check if we match a given set of <paramref name="otherParameters"/>
/// </summary>
/// <param name="otherParameters">The <see cref="DreamDaemonLaunchParameters"/> to compare against</param>
/// <returns><see langword="true"/> if they match, <see langword="false"/> otherwise</returns>
public bool Match(DreamDaemonLaunchParameters otherParameters) =>
AllowWebClient == otherParameters.AllowWebClient
&& SecurityLevel == otherParameters.SecurityLevel
&& PrimaryPort == otherParameters.PrimaryPort
&& SecondaryPort == otherParameters.SecondaryPort
&& StartupTimeout == otherParameters.StartupTimeout;
}
}
@@ -617,6 +617,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
{
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
if (launchParameters.Match(ActiveLaunchParameters))
return;
ActiveLaunchParameters = launchParameters;
if (Running)
//queue an update
@@ -780,6 +782,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task<WatchdogLaunchResult> Restart(bool graceful, CancellationToken cancellationToken)
{
logger.LogTrace("Begin Restart. Graceful: {0}", graceful);
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
{
if (!graceful || !Running)