diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs index 6dd03762..1ce09006 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientOperationTests.cs @@ -65,7 +65,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations sessionContext.Next = session.Object; proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); - sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0); + sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0, 0); } [TestMethod] @@ -112,7 +112,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations var terminateClient = new Action(() => Task.Delay(100).ContinueWith(_ => process.Raise(p => p.Terminated += null, 0))); processFactory.Setup(f => f.StartNew(It.IsAny(), It.IsAny())).Returns(process.Object).Callback(terminateClient); - sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, ONE_SECOND); + sut = new ClientOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, ONE_SECOND, ONE_SECOND); before = DateTime.Now; result = sut.Perform(); diff --git a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientTerminationOperationTests.cs b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientTerminationOperationTests.cs index 8a5a8248..b1ac3b4e 100644 --- a/SafeExamBrowser.Runtime.UnitTests/Operations/ClientTerminationOperationTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/Operations/ClientTerminationOperationTests.cs @@ -62,7 +62,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Operations sessionContext.Next = session.Object; proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny())).Returns(proxy.Object); - sut = new ClientTerminationOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0); + sut = new ClientTerminationOperation(logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, sessionContext, 0, 0); } [TestMethod] diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index baf3efec..dbff15a3 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -50,6 +50,7 @@ namespace SafeExamBrowser.Runtime { const int FIVE_SECONDS = 5000; const int FIFTEEN_SECONDS = 15000; + const int THIRTY_SECONDS = 30000; var args = Environment.GetCommandLineArgs(); var nativeMethods = new NativeMethods(); @@ -79,11 +80,11 @@ namespace SafeExamBrowser.Runtime sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext)); sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext)); - sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, FIFTEEN_SECONDS)); + sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS, FIFTEEN_SECONDS)); sessionOperations.Enqueue(new KioskModeTerminationOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext)); sessionOperations.Enqueue(new ServiceOperation(logger, serviceProxy, sessionContext)); sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext)); - sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, FIFTEEN_SECONDS)); + sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS, FIFTEEN_SECONDS)); sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext)); var bootstrapSequence = new OperationSequence(logger, bootstrapOperations); diff --git a/SafeExamBrowser.Runtime/Operations/ClientOperation.cs b/SafeExamBrowser.Runtime/Operations/ClientOperation.cs index 997ed020..2cae4ca9 100644 --- a/SafeExamBrowser.Runtime/Operations/ClientOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ClientOperation.cs @@ -21,8 +21,8 @@ namespace SafeExamBrowser.Runtime.Operations { internal class ClientOperation : SessionOperation { - private readonly int timeout_ms; - + private readonly int startup_timeout_ms; + private readonly int shutdown_timeout_ms; private ILogger logger; private IProcessFactory processFactory; private IProxyFactory proxyFactory; @@ -49,13 +49,15 @@ namespace SafeExamBrowser.Runtime.Operations IProxyFactory proxyFactory, IRuntimeHost runtimeHost, SessionContext sessionContext, - int timeout_ms) : base(sessionContext) + int startup_timeout_ms, + int shutdown_timeout_ms) : base(sessionContext) { this.logger = logger; this.processFactory = processFactory; this.proxyFactory = proxyFactory; this.runtimeHost = runtimeHost; - this.timeout_ms = timeout_ms; + this.startup_timeout_ms = startup_timeout_ms; + this.shutdown_timeout_ms = shutdown_timeout_ms; } public override OperationResult Perform() @@ -117,7 +119,7 @@ namespace SafeExamBrowser.Runtime.Operations ClientProcess.Terminated += clientTerminatedEventHandler; logger.Info("Waiting for client to complete initialization..."); - clientReady = clientReadyEvent.WaitOne(timeout_ms); + clientReady = clientReadyEvent.WaitOne(startup_timeout_ms); runtimeHost.AllowConnection = false; runtimeHost.ClientReady -= clientReadyEventHandler; @@ -130,7 +132,7 @@ namespace SafeExamBrowser.Runtime.Operations if (!clientReady) { - logger.Error($"Failed to start client within {timeout_ms / 1000} seconds!"); + logger.Error($"Failed to start client within {startup_timeout_ms / 1000} seconds!"); } if (clientTerminated) @@ -198,19 +200,19 @@ namespace SafeExamBrowser.Runtime.Operations ClientProxy.Disconnect(); logger.Info("Waiting for client to disconnect from runtime communication host..."); - disconnected = disconnectedEvent.WaitOne(timeout_ms); + disconnected = disconnectedEvent.WaitOne(shutdown_timeout_ms); if (!disconnected) { - logger.Error($"Client failed to disconnect within {timeout_ms / 1000} seconds!"); + logger.Error($"Client failed to disconnect within {shutdown_timeout_ms / 1000} seconds!"); } logger.Info("Waiting for client process to terminate..."); - terminated = terminatedEvent.WaitOne(timeout_ms); + terminated = terminatedEvent.WaitOne(shutdown_timeout_ms); if (!terminated) { - logger.Error($"Client failed to terminate within {timeout_ms / 1000} seconds!"); + logger.Error($"Client failed to terminate within {shutdown_timeout_ms / 1000} seconds!"); } runtimeHost.ClientDisconnected -= disconnectedEventHandler; diff --git a/SafeExamBrowser.Runtime/Operations/ClientTerminationOperation.cs b/SafeExamBrowser.Runtime/Operations/ClientTerminationOperation.cs index c8f13b16..bb3e7e3f 100644 --- a/SafeExamBrowser.Runtime/Operations/ClientTerminationOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/ClientTerminationOperation.cs @@ -22,7 +22,8 @@ namespace SafeExamBrowser.Runtime.Operations IProxyFactory proxyFactory, IRuntimeHost runtimeHost, SessionContext sessionContext, - int timeout_ms) : base(logger, processFactory, proxyFactory, runtimeHost, sessionContext, timeout_ms) + int startup_timeout_ms, + int shutdown_timeout_ms) : base(logger, processFactory, proxyFactory, runtimeHost, sessionContext, startup_timeout_ms, shutdown_timeout_ms) { }