CA-293863: Do not update the done and in-progress actions on the worker thread.

Also, do not log error every time the output panel is updated.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-07-16 11:16:33 +01:00 committed by Mihaela Stoica
parent c67abdb9b8
commit d639708781

View File

@ -189,30 +189,35 @@ namespace XenAdmin.Wizards.PatchingWizard
private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e) private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
{ {
var actionsWorker = sender as UpdateProgressBackgroundWorker; var bgw = sender as UpdateProgressBackgroundWorker;
if (actionsWorker == null) if (bgw == null)
return; return;
if (!actionsWorker.CancellationPending) if (!bgw.CancellationPending)
{ {
PlanAction action = (PlanAction)e.UserState; PlanAction action = (PlanAction)e.UserState;
if (action != null) if (action != null)
{ {
if (!action.IsComplete) if (!action.IsComplete)
{ {
if (!actionsWorker.InProgressActions.Contains(action)) if (!bgw.InProgressActions.Contains(action))
actionsWorker.InProgressActions.Add(action); bgw.InProgressActions.Add(action);
} }
else else
{ {
if (!actionsWorker.DoneActions.Contains(action)) if (!bgw.DoneActions.Contains(action))
actionsWorker.DoneActions.Add(action); bgw.DoneActions.Add(action);
actionsWorker.InProgressActions.Remove(action); bgw.InProgressActions.Remove(action);
if (action.Error == null) if (action.Error == null)
{ {
// remove the successful action from the cleanup actions (we are running the cleanup actions in case of failures or if the user cancelled the process, but we shouldn't re-run the actions that have already been run) // remove the successful action from the cleanup actions (we are running the cleanup actions in case of failures or if the user cancelled the process, but we shouldn't re-run the actions that have already been run)
actionsWorker.CleanupActions.Remove(action); bgw.CleanupActions.Remove(action);
}
else
{
if (!failedWorkers.Contains(bgw))
failedWorkers.Add(bgw);
} }
} }
} }
@ -255,17 +260,7 @@ namespace XenAdmin.Wizards.PatchingWizard
} }
var innerEx = pa.Error.InnerException as Failure; var innerEx = pa.Error.InnerException as Failure;
if (innerEx != null) errorSb.AppendLine(innerEx == null ? pa.Error.Message : innerEx.Message);
{
log.Error(innerEx);
errorSb.AppendLine(innerEx.Message);
}
else
{
log.Error(pa.Error);
errorSb.AppendLine(pa.Error.Message);
}
bgwErrorCount++; bgwErrorCount++;
} }
} }
@ -385,14 +380,8 @@ namespace XenAdmin.Wizards.PatchingWizard
if (action.Error == null) if (action.Error == null)
action.Error = new Exception(Messages.ERROR_UNKNOWN); action.Error = new Exception(Messages.ERROR_UNKNOWN);
if (!bgw.DoneActions.Contains(action))
bgw.DoneActions.Add(action);
bgw.InProgressActions.Remove(action);
log.ErrorFormat("Failed to carry out plan. {0} {1}", action.CurrentProgressStep, e); log.ErrorFormat("Failed to carry out plan. {0} {1}", action.CurrentProgressStep, e);
doWorkEventArgs.Result = new Exception(action.CurrentProgressStep, e); doWorkEventArgs.Result = new Exception(action.CurrentProgressStep, e);
failedWorkers.Add(bgw);
} }
} }