Browse code

Fix closing attach streams on lost tcp connection

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/04/07 08:49:45
Showing 1 changed files
... ...
@@ -51,6 +51,7 @@ func (bp *BytesPipe) Write(p []byte) (int, error) {
51 51
 	bp.mu.Lock()
52 52
 
53 53
 	written := 0
54
+loop0:
54 55
 	for {
55 56
 		if bp.closeErr != nil {
56 57
 			bp.mu.Unlock()
... ...
@@ -85,6 +86,9 @@ func (bp *BytesPipe) Write(p []byte) (int, error) {
85 85
 		// make sure the buffer doesn't grow too big from this write
86 86
 		for bp.bufLen >= blockThreshold {
87 87
 			bp.wait.Wait()
88
+			if bp.closeErr != nil {
89
+				continue loop0
90
+			}
88 91
 		}
89 92
 
90 93
 		// add new byte slice to the buffers slice and continue writing