瀏覽代碼

Fix closing attach streams on lost tcp connection

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 9 年之前
父節點
當前提交
a47cd63915
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      pkg/ioutils/bytespipe.go

+ 4 - 0
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