Fixed race condition between service and runtime, occurring when the runtime initiated a new session before the service was able to terminate the currently running one.

This commit is contained in:
dbuechel 2019-09-25 08:25:51 +02:00
parent 0159b9c0de
commit 6511401fa4

View file

@ -42,10 +42,16 @@ namespace SafeExamBrowser.Service.Operations
public override OperationResult Revert()
{
var success = true;
var wasRunning = Context.IsRunning;
logger.Info("Finalizing current session...");
logger.Info("Starting auto-restore mechanism...");
Context.AutoRestoreMechanism.Start();
if (Context.ServiceEvent != null && Context.IsRunning)
logger.Info("Clearing session data...");
Context.Configuration = null;
Context.IsRunning = false;
if (Context.ServiceEvent != null && wasRunning)
{
success = Context.ServiceEvent.Set();
@ -59,13 +65,6 @@ namespace SafeExamBrowser.Service.Operations
}
}
logger.Info("Starting auto-restore mechanism...");
Context.AutoRestoreMechanism.Start();
logger.Info("Clearing session data...");
Context.Configuration = null;
Context.IsRunning = false;
return success ? OperationResult.Success : OperationResult.Failed;
}