mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-28 12:31:04 +00:00
Merge pull request #9367 from microsoft/danmihai1/infinite-io-stream-copy-loop
runtime: remove stream copy infinite loop
This commit is contained in:
commit
3a7dbcfc17
@ -10,9 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -127,20 +125,7 @@ func ioCopy(shimLog *logrus.Entry, exitch, stdinCloser chan struct{}, tty *ttyIO
|
|||||||
shimLog.Debug("stdout io stream copy started")
|
shimLog.Debug("stdout io stream copy started")
|
||||||
p := bufPool.Get().(*[]byte)
|
p := bufPool.Get().(*[]byte)
|
||||||
defer bufPool.Put(p)
|
defer bufPool.Put(p)
|
||||||
|
io.CopyBuffer(tty.io.Stdout(), stdoutPipe, *p)
|
||||||
for {
|
|
||||||
var _, err = io.CopyBuffer(tty.io.Stdout(), stdoutPipe, *p)
|
|
||||||
if err != nil {
|
|
||||||
shimLog.Debug("stdout io stream copy error happens: error = %w", err.Error())
|
|
||||||
if !strings.Contains(err.Error(), "blocked by policy") {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if tty.io.Stdin() != nil {
|
if tty.io.Stdin() != nil {
|
||||||
// close stdin to make the other routine stop
|
// close stdin to make the other routine stop
|
||||||
tty.io.Stdin().Close()
|
tty.io.Stdin().Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user