From 7d530125bf32cae999daa739161dde93b690641e Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Thu, 30 Jul 2020 15:21:18 +0100 Subject: [PATCH] Fix GH13248 --- .../remoting/commands/CustomShellCommands.cs | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index dde4422de45..71985462fc5 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -3571,56 +3571,6 @@ private void SetQuotas() Hashtable quotas = transportOption.ConstructQuotasAsHashtable(); - int idleTimeOut = 0; - - if (idleTimeOut != 0 && quotas.ContainsKey(WSManConfigurationOption.AttribMaxIdleTimeout)) - { - bool setMaxIdleTimeoutFirst = true; - int maxIdleTimeOut; - - if (LanguagePrimitives.TryConvertTo(quotas[WSManConfigurationOption.AttribMaxIdleTimeout], out maxIdleTimeOut)) - { - int? currentIdleTimeoutms = WSManConfigurationOption.DefaultIdleTimeout; - - // Get the current IdleTimeOut quota value - // - using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) - { - ps.AddScript(string.Format(CultureInfo.InvariantCulture, getCurrentIdleTimeoutmsFormat, CodeGeneration.EscapeSingleQuotedStringContent(Name))); - Collection psObjectCollection = ps.Invoke(new object[] { Name }) as Collection; - if (psObjectCollection == null || psObjectCollection.Count != 1) - { - Dbg.Assert(false, "This should never happen. ps.Invoke always return a Collection"); - } - - currentIdleTimeoutms = Convert.ToInt32(psObjectCollection[0].ToString(), CultureInfo.InvariantCulture); - } - - if (currentIdleTimeoutms >= maxIdleTimeOut && currentIdleTimeoutms >= idleTimeOut) - { - setMaxIdleTimeoutFirst = false; - } - } - - ScriptBlock setTimeoutQuotasSb = ScriptBlock.Create( - string.Format(CultureInfo.InvariantCulture, setSessionConfigurationTimeoutQuotasSbFormat, CodeGeneration.EscapeSingleQuotedStringContent(Name))); - setTimeoutQuotasSb.LanguageMode = PSLanguageMode.FullLanguage; - - setTimeoutQuotasSb.InvokeUsingCmdlet( - contextCmdlet: this, - useLocalScope: true, - errorHandlingBehavior: ScriptBlock.ErrorHandlingBehavior.WriteToCurrentErrorPipe, - dollarUnder: AutomationNull.Value, - input: Array.Empty(), - scriptThis: AutomationNull.Value, - args: new object[] { maxIdleTimeOut, idleTimeOut, setMaxIdleTimeoutFirst }); - - // Remove Idle timeout values as we have set them above - // - quotas.Remove(WSManConfigurationOption.AttribMaxIdleTimeout); - quotas.Remove(WSManConfigurationOption.AttribIdleTimeout); - } - setQuotasSb.InvokeUsingCmdlet( contextCmdlet: this, useLocalScope: true,