mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add a stdincloser to container.Attach in order to close the client connection when needed
This commit is contained in:
parent
43484e8b50
commit
6882c78ce4
3 changed files with 39 additions and 16 deletions
|
@ -93,9 +93,7 @@ func TestRunExit(t *testing.T) {
|
|||
stdout, stdoutPipe := io.Pipe()
|
||||
c1 := make(chan struct{})
|
||||
go func() {
|
||||
if err := srv.CmdRun(stdin, stdoutPipe, "-i", GetTestImage(runtime).Id, "/bin/cat"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
srv.CmdRun(stdin, stdoutPipe, "-i", GetTestImage(runtime).Id, "/bin/cat")
|
||||
close(c1)
|
||||
}()
|
||||
|
||||
|
@ -123,11 +121,8 @@ func TestRunExit(t *testing.T) {
|
|||
|
||||
// Make sure that the client has been disconnected
|
||||
setTimeout(t, "The client should have been disconnected once the remote process exited.", 2*time.Second, func() {
|
||||
if _, err := stdin.Read([]byte{}); err != nil {
|
||||
if err != io.EOF {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// Expecting pipe i/o error, just check that read does not block
|
||||
stdin.Read([]byte{})
|
||||
})
|
||||
|
||||
// Cleanup pipes
|
||||
|
@ -293,6 +288,7 @@ func TestAttachDisconnect(t *testing.T) {
|
|||
setTimeout(t, "Waiting for CmdAttach timed out", 2*time.Second, func() {
|
||||
<-c1
|
||||
})
|
||||
|
||||
// We closed stdin, expect /bin/cat to still be running
|
||||
// Wait a little bit to make sure container.monitor() did his thing
|
||||
err = container.WaitTimeout(500 * time.Millisecond)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue