Skip to content

Commit

Permalink
Merge pull request #13 from hhgyu/hhgyu-patch-1
Browse files Browse the repository at this point in the history
Powershell 7.4.1 버전업데이트 이후 pipe stream의 끝을 감지하지 못하고 hangs이 걸리는 문제 수정
  • Loading branch information
hhgyu committed Feb 2, 2024
2 parents 1e33e2c + 451dc98 commit 98c769d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 22 deletions.
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()
}
}
}

0 comments on commit 98c769d

Please sign in to comment.