From b1b86e91667939491a471dc7604780ebc1661e25 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 (cherry picked from commit a47cd639158ee9cfd228c0ae8257301b8510f3ad) --- pkg/ioutils/bytespipe.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/ioutils/bytespipe.go b/pkg/ioutils/bytespipe.go index e263c284f0..fcaecc37b5 100644 --- a/pkg/ioutils/bytespipe.go +++ b/pkg/ioutils/bytespipe.go @@ -49,6 +49,7 @@ func (bp *BytesPipe) Write(p []byte) (int, error) { bp.mu.Lock() defer bp.mu.Unlock() written := 0 +loop0: for { if bp.closeErr != nil { return written, ErrClosed @@ -75,6 +76,9 @@ func (bp *BytesPipe) Write(p []byte) (int, error) { // block if too much data is still in the buffer for bp.bufLen >= blockThreshold { bp.wait.Wait() + if bp.closeErr != nil { + continue loop0 + } } // allocate slice that has twice the size of the last unless maximum reached