Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell 7.4.1 버전업데이트 이후 pipe stream의 끝을 감지하지 못하고 hangs이 걸리는 문제 수정 #13

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
37 changes: 29 additions & 8 deletions dist/setup/scripts/VC-Pipe.ps1
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -35,4 +56,4 @@ finally {
if ($client.IsConnected -eq $True) {
$client.Close()
}
}
}
37 changes: 29 additions & 8 deletions scripts/VC-Pipe.ps1
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -35,4 +56,4 @@ finally {
if ($client.IsConnected -eq $True) {
$client.Close()
}
}
}