Prevent sending interop to finished session controllers.

This commit is contained in:
Jordan Brown
2020-01-05 12:17:40 -05:00
parent a6ec5f6054
commit e4df4cfd09
2 changed files with 12 additions and 0 deletions
@@ -447,6 +447,15 @@ namespace Tgstation.Server.Host.Components.Watchdog
async Task<string> SendCommand(string command, ushort? overridePort, CancellationToken cancellationToken)
{
if (Lifetime.IsCompleted)
{
logger.LogWarning(
"Attempted to send a command to an inactive SessionController{1}: {0}",
command,
overridePort.HasValue ? $" (Override port: {overridePort.Value})" : String.Empty);
return null;
}
try
{
var commandString = String.Format(CultureInfo.InvariantCulture,
@@ -426,6 +426,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
/// <inheritdoc />
public async Task<bool> HandleEvent(EventType eventType, IEnumerable<string> parameters, CancellationToken cancellationToken)
{
if (!Running)
return true;
string results;
using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false))
{