mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #6637 from jwhonce/issues/6574
Correct logic for demux'ing channels
This commit is contained in:
@ -178,25 +178,28 @@ func Attach(ctx context.Context, nameOrID string, detachKeys *string, logs, stre
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case fd == 0 && isSet.stdout:
|
case fd == 0:
|
||||||
_, err := stdout.Write(frame[0:l])
|
if isSet.stdout {
|
||||||
if err != nil {
|
if _, err := stdout.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 1 && isSet.stdout:
|
case fd == 1:
|
||||||
_, err := stdout.Write(frame[0:l])
|
if isSet.stdout {
|
||||||
if err != nil {
|
if _, err := stdout.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 2 && isSet.stderr:
|
case fd == 2:
|
||||||
_, err := stderr.Write(frame[0:l])
|
if isSet.stderr {
|
||||||
if err != nil {
|
if _, err := stderr.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 3:
|
case fd == 3:
|
||||||
return fmt.Errorf("error from service from stream: %s", frame)
|
return fmt.Errorf("error from service from stream: %s", frame)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unrecognized channel in header: %d, 0-3 supported", fd)
|
return fmt.Errorf("unrecognized channel '%d' in header, 0-3 supported", fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,27 +456,30 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, streams *define.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case fd == 0 && streams.AttachOutput:
|
case fd == 0:
|
||||||
_, err := streams.OutputStream.Write(frame[0:l])
|
if streams.AttachOutput {
|
||||||
if err != nil {
|
if _, err := streams.OutputStream.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 1 && streams.AttachInput:
|
case fd == 1:
|
||||||
// Write STDIN to STDOUT (echoing characters
|
if streams.AttachInput {
|
||||||
// typed by another attach session)
|
// Write STDIN to STDOUT (echoing characters
|
||||||
_, err := streams.OutputStream.Write(frame[0:l])
|
// typed by another attach session)
|
||||||
if err != nil {
|
if _, err := streams.OutputStream.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 2 && streams.AttachError:
|
case fd == 2:
|
||||||
_, err := streams.ErrorStream.Write(frame[0:l])
|
if streams.AttachError {
|
||||||
if err != nil {
|
if _, err := streams.ErrorStream.Write(frame[0:l]); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case fd == 3:
|
case fd == 3:
|
||||||
return fmt.Errorf("error from service from stream: %s", frame)
|
return fmt.Errorf("error from service from stream: %s", frame)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unrecognized channel in header: %d, 0-3 supported", fd)
|
return fmt.Errorf("unrecognized channel '%d' in header, 0-3 supported", fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user