Browse Source

integration: close accepted connection on stopc path

Connection pausing added another exit condition in the listener
path, causing the bridge to leak connections instead of closing
them when signalled to close. Also adds some additional Close
paranoia.

Fixes #7823
Anthony Romano 8 years ago
parent
commit
61abf25859
1 changed files with 8 additions and 1 deletions
  1. 8 1
      integration/bridge.go

+ 8 - 1
integration/bridge.go

@@ -119,6 +119,7 @@ func (b *bridge) serveListen() {
 		b.mu.Unlock()
 		b.mu.Unlock()
 		select {
 		select {
 		case <-b.stopc:
 		case <-b.stopc:
+			inc.Close()
 			return
 			return
 		case <-pausec:
 		case <-pausec:
 		}
 		}
@@ -152,10 +153,12 @@ func (b *bridge) serveConn(bc *bridgeConn) {
 	wg.Add(2)
 	wg.Add(2)
 	go func() {
 	go func() {
 		io.Copy(bc.out, bc.in)
 		io.Copy(bc.out, bc.in)
+		bc.close()
 		wg.Done()
 		wg.Done()
 	}()
 	}()
 	go func() {
 	go func() {
 		io.Copy(bc.in, bc.out)
 		io.Copy(bc.in, bc.out)
+		bc.close()
 		wg.Done()
 		wg.Done()
 	}()
 	}()
 	wg.Wait()
 	wg.Wait()
@@ -168,7 +171,11 @@ type bridgeConn struct {
 }
 }
 
 
 func (bc *bridgeConn) Close() {
 func (bc *bridgeConn) Close() {
+	bc.close()
+	<-bc.donec
+}
+
+func (bc *bridgeConn) close() {
 	bc.in.Close()
 	bc.in.Close()
 	bc.out.Close()
 	bc.out.Close()
-	<-bc.donec
 }
 }