1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

test: add buffer to prevent goroutine leak

Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
This commit is contained in:
Ziheng Liu
2020-02-25 17:13:25 -05:00
parent d706420b5d
commit c322af8019
22 changed files with 63 additions and 45 deletions

View File

@ -43,14 +43,14 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
expected := []byte("hello")
actual := make([]byte, len(expected))
outChan := make(chan error)
outChan := make(chan error, 1)
go func() {
_, err := io.ReadFull(ws, actual)
outChan <- err
close(outChan)
}()
inChan := make(chan error)
inChan := make(chan error, 1)
go func() {
_, err := ws.Write(expected)
inChan <- err
@ -278,7 +278,7 @@ func bodyIsWritable(r *http.Response) bool {
// readTimeout read from io.Reader with timeout
func readTimeout(r io.Reader, buf []byte, timeout time.Duration) (n int, err error) {
ch := make(chan bool)
ch := make(chan bool, 1)
go func() {
n, err = io.ReadFull(r, buf)
ch <- true