From 451dc98355dca9145be9a5981c7a3bfde3f847c0 Mon Sep 17 00:00:00 2001 From: HongHakGyu Date: Fri, 2 Feb 2024 19:35:00 +0900 Subject: [PATCH] =?UTF-8?q?Powershell=207.4.1=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=9D=B4=ED=9B=84=20pip?= =?UTF-8?q?e=20stream=EC=9D=98=20=EB=81=9D=EC=9D=84=20=EA=B0=90=EC=A7=80?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EB=AA=BB=ED=95=98=EA=B3=A0=20hangs?= =?UTF-8?q?=EC=9D=B4=20=EA=B1=B8=EB=A6=AC=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 512kb 버퍼에 한번에 읽고 끝나도록 변경 --- .github/dependabot.yml | 12 +++++------ dist/setup/scripts/VC-Pipe.ps1 | 37 ++++++++++++++++++++++++++-------- scripts/VC-Pipe.ps1 | 37 ++++++++++++++++++++++++++-------- 3 files changed, 64 insertions(+), 22 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 92995f5..04f278b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,13 +5,13 @@ version: 2 updates: - - package-ecosystem: "github-actions" + - package-ecosystem: 'github-actions' # Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.) - directory: "/" + directory: '/' schedule: - interval: "weekly" + interval: 'weekly' - - package-ecosystem: "npm" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: 'npm' # See documentation for possible values + directory: '/' # Location of package manifests schedule: - interval: "weekly" + interval: 'weekly' diff --git a/dist/setup/scripts/VC-Pipe.ps1 b/dist/setup/scripts/VC-Pipe.ps1 index bec382a..202f9e5 100644 --- a/dist/setup/scripts/VC-Pipe.ps1 +++ b/dist/setup/scripts/VC-Pipe.ps1 @@ -1,3 +1,19 @@ +function Await-Task { + param ( + [Parameter(ValueFromPipeline=$true, Mandatory=$true)] + $task + ) + + process { + $start = (Get-Date) + while (-not $task.AsyncWaitHandle.WaitOne(200)) { + if ((Get-Date).Subtract($start).TotalMilliseconds -gt 5000) { + throw [System.TimeoutException]::new("Read Timeout") + } + } + $task.GetAwaiter().GetResult() + } +} $client = [System.IO.Pipes.NamedPipeClientStream]::new(".", "vhclient", [System.IO.Pipes.PipeDirection]::InOut) try { $client.Connect(5000) @@ -7,15 +23,20 @@ try { $writer.AutoFlush = $True $writer.Write($Args[0].ToCharArray()) Start-Sleep -Milliseconds 200 + + $reader = [System.IO.StreamReader]::new($client, [System.Text.Encoding]::UTF8) + $chars = [System.Collections.Generic.List[char]]::new() - $reader = [System.IO.StreamReader]::new($client) - $start = (Get-Date) - while ($reader.Peek() -ne -1) { - if ((Get-Date).Subtract($start).TotalMilliseconds -gt 5000) { - throw [System.TimeoutException]::new("Read Timeout") + + $temp = [char[]]::new(512000) + $task = $reader.ReadAsync($temp, 0, 512000) + + $ret = $task | Await-Task + $task.Dispose() + if($ret -ne 0) { + foreach($i in 0..$task.Result){ + $chars.Add($temp[$i]) } - - $chars.Add($reader.Read()) } $ret = [System.Text.Encoding]::UTF8.GetString($chars) @@ -35,4 +56,4 @@ finally { if ($client.IsConnected -eq $True) { $client.Close() } -} \ No newline at end of file +} diff --git a/scripts/VC-Pipe.ps1 b/scripts/VC-Pipe.ps1 index bec382a..202f9e5 100644 --- a/scripts/VC-Pipe.ps1 +++ b/scripts/VC-Pipe.ps1 @@ -1,3 +1,19 @@ +function Await-Task { + param ( + [Parameter(ValueFromPipeline=$true, Mandatory=$true)] + $task + ) + + process { + $start = (Get-Date) + while (-not $task.AsyncWaitHandle.WaitOne(200)) { + if ((Get-Date).Subtract($start).TotalMilliseconds -gt 5000) { + throw [System.TimeoutException]::new("Read Timeout") + } + } + $task.GetAwaiter().GetResult() + } +} $client = [System.IO.Pipes.NamedPipeClientStream]::new(".", "vhclient", [System.IO.Pipes.PipeDirection]::InOut) try { $client.Connect(5000) @@ -7,15 +23,20 @@ try { $writer.AutoFlush = $True $writer.Write($Args[0].ToCharArray()) Start-Sleep -Milliseconds 200 + + $reader = [System.IO.StreamReader]::new($client, [System.Text.Encoding]::UTF8) + $chars = [System.Collections.Generic.List[char]]::new() - $reader = [System.IO.StreamReader]::new($client) - $start = (Get-Date) - while ($reader.Peek() -ne -1) { - if ((Get-Date).Subtract($start).TotalMilliseconds -gt 5000) { - throw [System.TimeoutException]::new("Read Timeout") + + $temp = [char[]]::new(512000) + $task = $reader.ReadAsync($temp, 0, 512000) + + $ret = $task | Await-Task + $task.Dispose() + if($ret -ne 0) { + foreach($i in 0..$task.Result){ + $chars.Add($temp[$i]) } - - $chars.Add($reader.Read()) } $ret = [System.Text.Encoding]::UTF8.GetString($chars) @@ -35,4 +56,4 @@ finally { if ($client.IsConnected -eq $True) { $client.Close() } -} \ No newline at end of file +}