mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 06:16:37 +01:00
CP-36392: Update RebootPlanAction.cs to lock on a dedicated object instance
Use dedicated instance to avoid deadlocks or lock contention Also fix typo and rename `private` variable Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
parent
df53a4cd98
commit
cfc7bd0ef9
@ -39,7 +39,8 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
public abstract class RebootPlanAction : HostPlanAction
|
||||
{
|
||||
private bool _cancelled;
|
||||
private bool lostConnection;
|
||||
private bool _lostConnection;
|
||||
private readonly object _lockObj = new object();
|
||||
|
||||
protected RebootPlanAction(Host host)
|
||||
: base(host)
|
||||
@ -50,9 +51,9 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
{
|
||||
_cancelled = true;
|
||||
|
||||
lock (this)
|
||||
lock (_lockObj)
|
||||
{
|
||||
Monitor.PulseAll(this);
|
||||
Monitor.PulseAll(_lockObj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +99,7 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
{
|
||||
bool isCoordinator = GetResolvedHost().IsCoordinator();
|
||||
|
||||
lostConnection = false;
|
||||
_lostConnection = false;
|
||||
_cancelled = false;
|
||||
double metric = metricDelegate(session, HostXenRef.opaque_ref);
|
||||
|
||||
@ -134,7 +135,7 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
Connection.SuppressErrors = true;
|
||||
|
||||
//
|
||||
// Wait for a dissconnection
|
||||
// Wait for a disconnection
|
||||
//
|
||||
|
||||
WaitForDisconnection();
|
||||
@ -165,11 +166,11 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
{
|
||||
log.DebugFormat("{0}._WaitForReboot waiting for connection to go away...", GetType().Name);
|
||||
|
||||
lock (this)
|
||||
lock (_lockObj)
|
||||
{
|
||||
while (!lostConnection && !_cancelled)
|
||||
while (!_lostConnection && !_cancelled)
|
||||
{
|
||||
Monitor.Wait(this);
|
||||
Monitor.Wait(_lockObj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,10 +275,10 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
|
||||
private void connection_ConnectionLost(IXenConnection conn)
|
||||
{
|
||||
lock (this)
|
||||
lock (_lockObj)
|
||||
{
|
||||
lostConnection = true;
|
||||
Monitor.PulseAll(this);
|
||||
_lostConnection = true;
|
||||
Monitor.PulseAll(_lockObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user