Skip to content

Commit 136213d

Browse files
PaulHigindaxian-dbw
authored andcommitted
Fix for race bug in WSMan command plugin instance close operation (PowerShell#3203)
1 parent 8cf7989 commit 136213d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,13 @@ internal void CloseShellOperation(
473473
return;
474474
}
475475

476-
SetThreadProperties(mgdShellSession.creationRequestDetails);
477476
// update the internal data store only if this is not receive operation.
478477
if (!context.isReceiveOperation)
479478
{
480479
DeleteFromActiveShellSessions(context.shellContext);
481480
}
482481

483-
string errorMsg = StringUtil.Format(RemotingErrorIdStrings.WSManPluginOperationClose);
484-
System.Exception reasonForClose = new System.Exception(errorMsg);
482+
System.Exception reasonForClose = new System.Exception(RemotingErrorIdStrings.WSManPluginOperationClose);
485483
mgdShellSession.CloseOperation(context, reasonForClose);
486484
}
487485

@@ -502,7 +500,7 @@ internal void CloseCommandOperation(
502500
//Dbg.Assert(false, "context.shellContext not matched");
503501
return;
504502
}
505-
SetThreadProperties(mgdShellSession.creationRequestDetails);
503+
506504
mgdShellSession.CloseCommandOperation(context);
507505
}
508506

src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ internal override void CloseOperation(
698698
}
699699
}
700700

701+
WSManPluginInstance.SetThreadProperties(creationRequestDetails);
702+
701703
bool isRcvOpShuttingDown = (context.isShuttingDown) && (context.isReceiveOperation);
702704
bool isRcvOp = context.isReceiveOperation;
703705
bool isShuttingDown = context.isShuttingDown;
@@ -797,6 +799,8 @@ internal override void CloseOperation(
797799
}
798800
}
799801

802+
WSManPluginInstance.SetThreadProperties(creationRequestDetails);
803+
800804
bool isRcvOp = context.isReceiveOperation;
801805
// only one thread will be here.
802806
bool isRcvOpShuttingDown = (context.isShuttingDown) &&

0 commit comments

Comments
 (0)