зеркало из https://github.com/microsoft/BuildXL.git
Handle front-end cancellation at a higher level (#965)
Namely, in FrontEndHostController.ProcessPhase. AB#1608030
This commit is contained in:
Родитель
42166bacbf
Коммит
b62ce412a0
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче