mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
[CA-211267] Add a null check, use Run() to stop child classes directly calling InitialiseTicker()
TickUntilCompletion() is now a static method and again takes an ApplianceAction parameter. It does a null check on each while iteration to handle the case where another thread nulls the action. Also added Run() method to ApplianceAction which initialises the ticker (now a private method), and let child classes call Run() instead.
This commit is contained in:
parent
15b4705942
commit
7d7a040335
@ -82,6 +82,12 @@ namespace XenAdmin.Actions.OVFActions
|
||||
Host = Helpers.GetMaster(connection);
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
SafeToExit = false;
|
||||
InitialiseTicker();
|
||||
}
|
||||
|
||||
protected void UpdateHandler(XenOvfTranportEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Message))
|
||||
@ -101,16 +107,16 @@ namespace XenAdmin.Actions.OVFActions
|
||||
m_transportAction.Cancel = true;
|
||||
}
|
||||
|
||||
protected void InitialiseTicker()
|
||||
private void InitialiseTicker()
|
||||
{
|
||||
System.Threading.Tasks.Task.Run(() => TickUntilCompletion());
|
||||
System.Threading.Tasks.Task.Run(() => TickUntilCompletion(this));
|
||||
}
|
||||
|
||||
private void TickUntilCompletion()
|
||||
private static void TickUntilCompletion(ApplianceAction action)
|
||||
{
|
||||
while (!IsCompleted)
|
||||
while (action != null && !action.IsCompleted)
|
||||
{
|
||||
OnChanged();
|
||||
action.OnChanged();
|
||||
Thread.Sleep(SLEEP_TIME);
|
||||
}
|
||||
}
|
||||
|
@ -90,10 +90,9 @@ namespace XenAdmin.Actions.OVFActions
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
SafeToExit = false;
|
||||
var session = Connection.Session;
|
||||
base.Run();
|
||||
|
||||
InitialiseTicker();
|
||||
var session = Connection.Session;
|
||||
|
||||
var url = session.Url;
|
||||
Uri uri = new Uri(url);
|
||||
|
@ -76,9 +76,7 @@ namespace XenAdmin.Actions.OVFActions
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
SafeToExit = false;
|
||||
|
||||
InitialiseTicker();
|
||||
base.Run();
|
||||
|
||||
if (m_verifySignature)
|
||||
{
|
||||
|
@ -70,10 +70,9 @@ namespace XenAdmin.Actions.OVFActions
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
SafeToExit = false;
|
||||
Debug.Assert(m_vmMappings.Count == 1, "There is one VM mapping");
|
||||
base.Run();
|
||||
|
||||
InitialiseTicker();
|
||||
Debug.Assert(m_vmMappings.Count == 1, "There is one VM mapping");
|
||||
|
||||
string systemid = m_vmMappings.Keys.ElementAt(0);
|
||||
var mapping = m_vmMappings.Values.ElementAt(0);
|
||||
|
Loading…
Reference in New Issue
Block a user