From 61abf25859338506cd5f539393d422923969324a Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 2 May 2017 16:12:02 -0700 Subject: [PATCH] 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 --- integration/bridge.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/integration/bridge.go b/integration/bridge.go index 09c65aa1f..b9e67318e 100644 --- a/integration/bridge.go +++ b/integration/bridge.go @@ -119,6 +119,7 @@ func (b *bridge) serveListen() { b.mu.Unlock() select { case <-b.stopc: + inc.Close() return case <-pausec: } @@ -152,10 +153,12 @@ func (b *bridge) serveConn(bc *bridgeConn) { wg.Add(2) go func() { io.Copy(bc.out, bc.in) + bc.close() wg.Done() }() go func() { io.Copy(bc.in, bc.out) + bc.close() wg.Done() }() wg.Wait() @@ -168,7 +171,11 @@ type bridgeConn struct { } func (bc *bridgeConn) Close() { - bc.in.Close() - bc.out.Close() + bc.close() <-bc.donec } + +func (bc *bridgeConn) close() { + bc.in.Close() + bc.out.Close() +}