Handle front-end cancellation at a higher level (#965)

Namely, in FrontEndHostController.ProcessPhase.

AB#1608030
This commit is contained in:
Aleksandar Milicevic 2019-10-02 08:42:52 -07:00 коммит произвёл GitHub
Родитель 42166bacbf
Коммит b62ce412a0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 35 добавлений и 28 удалений

Просмотреть файл

@ -981,42 +981,49 @@ namespace BuildXL.FrontEnd.Core
PhaseLogicHandler<TStatistics> phaseLogicHandler)
where TStatistics : IHasEndTime
{
var loggingContext = new LoggingContext(FrontEndContext.LoggingContext, phase.ToString());
if (configuration.Engine.Phase.HasFlag(phase))
try
{
var statistics = default(TStatistics);
using (var aggregator = m_collector?.CreateAggregator())
var loggingContext = new LoggingContext(FrontEndContext.LoggingContext, phase.ToString());
if (configuration.Engine.Phase.HasFlag(phase))
{
var stopwatch = Stopwatch.StartNew();
startPhaseLogMessage(loggingContext);
var statistics = default(TStatistics);
m_frontEndFactory.GetPhaseStartHook(phase)();
var success = phaseLogicHandler(loggingContext, ref statistics);
m_frontEndFactory.GetPhaseEndHook(phase)();
LaunchDebuggerIfConfigured(phase);
statistics.ElapsedMilliseconds = (int)stopwatch.ElapsedMilliseconds;
// Call the endPhase handler for both: error and successful cases,
// but not if the unhandled exception will occur.
endPhaseLogMessage(loggingContext, statistics);
if (aggregator != null)
using (var aggregator = m_collector?.CreateAggregator())
{
LoggingHelpers.LogPerformanceCollector(aggregator, loggingContext, loggingContext.LoggerComponentInfo, statistics.ElapsedMilliseconds);
}
var stopwatch = Stopwatch.StartNew();
startPhaseLogMessage(loggingContext);
if (!success)
{
Contract.Assume(loggingContext.ErrorWasLogged, "An error should have been logged after frontend phase: " + phase.ToString());
return false;
m_frontEndFactory.GetPhaseStartHook(phase)();
var success = phaseLogicHandler(loggingContext, ref statistics);
m_frontEndFactory.GetPhaseEndHook(phase)();
LaunchDebuggerIfConfigured(phase);
statistics.ElapsedMilliseconds = (int)stopwatch.ElapsedMilliseconds;
// Call the endPhase handler for both: error and successful cases,
// but not if the unhandled exception will occur.
endPhaseLogMessage(loggingContext, statistics);
if (aggregator != null)
{
LoggingHelpers.LogPerformanceCollector(aggregator, loggingContext, loggingContext.LoggerComponentInfo, statistics.ElapsedMilliseconds);
}
if (!success)
{
Contract.Assume(loggingContext.ErrorWasLogged, "An error should have been logged after frontend phase: " + phase.ToString());
return false;
}
}
}
}
return true;
return true;
}
catch (OperationCanceledException)
{
return false;
}
}
private static void LaunchDebuggerIfConfigured(EnginePhases phase)