From 5656f87b9672e39b72dec3c237936a7be5c12828 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 27 Sep 2018 10:47:26 -0400 Subject: [PATCH] Clean up direct X installation slightly --- .../Components/Byond/WindowsByondInstaller.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs index 99ac434050..5c1a83e18f 100644 --- a/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Byond/WindowsByondInstaller.cs @@ -121,16 +121,26 @@ namespace Tgstation.Server.Host.Components.Byond //after this version lummox made DD depend of directx lol if (version.Major >= 512 && version.Minor >= 1427 && !installedDirectX) using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false)) + //check again because race conditions if (!installedDirectX) { //always install it, it's pretty fast and will do better redundancy checking than us var rbdx = ioManager.ConcatPath(path, ByondDXDir); //noShellExecute because we aren't doing runas shennanigans - using (var p = processExecutor.LaunchProcess(ioManager.ConcatPath(rbdx, "DXSETUP.exe"), rbdx, "/silent", noShellExecute: true)) + IProcess directXInstaller; + try + { + directXInstaller = processExecutor.LaunchProcess(ioManager.ConcatPath(rbdx, "DXSETUP.exe"), rbdx, "/silent", noShellExecute: true); + } + catch (Exception e) + { + throw new JobException("Unable to start DirectX installer process! Is the server running with admin privileges?", e); + } + using (directXInstaller) { int exitCode; - using (cancellationToken.Register(() => p.Terminate())) - exitCode = await p.Lifetime.ConfigureAwait(false); + using (cancellationToken.Register(() => directXInstaller.Terminate())) + exitCode = await directXInstaller.Lifetime.ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); if (exitCode != 0)