Fix closing attach streams on lost tcp connection

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit a47cd63915)
This commit is contained in:
Tonis Tiigi 2016-04-06 16:49:45 -07:00 committed by Tibor Vass
parent 35d6def3aa
commit b1b86e9166
1 changed files with 4 additions and 0 deletions

View File

@ -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