From a47cd639158ee9cfd228c0ae8257301b8510f3ad Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 6 Apr 2016 16:49:45 -0700 Subject: [PATCH] Fix closing attach streams on lost tcp connection Signed-off-by: Tonis Tiigi --- pkg/ioutils/bytespipe.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/ioutils/bytespipe.go b/pkg/ioutils/bytespipe.go index f0d21debe5..59bba96265 100644 --- a/pkg/ioutils/bytespipe.go +++ b/pkg/ioutils/bytespipe.go @@ -51,6 +51,7 @@ func (bp *BytesPipe) Write(p []byte) (int, error) { bp.mu.Lock() written := 0 +loop0: for { if bp.closeErr != nil { bp.mu.Unlock() @@ -85,6 +86,9 @@ func (bp *BytesPipe) Write(p []byte) (int, error) { // make sure the buffer doesn't grow too big from this write for bp.bufLen >= blockThreshold { bp.wait.Wait() + if bp.closeErr != nil { + continue loop0 + } } // add new byte slice to the buffers slice and continue writing