Skip to content

Commit

Permalink
integration: close accepted connection on stopc path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Anthony Romano committed May 2, 2017
1 parent 43e5f89 commit 998acd9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion integration/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (b *bridge) serveListen() {
b.mu.Unlock()
select {
case <-b.stopc:
inc.Close()
return
case <-pausec:
}
Expand Down Expand Up @@ -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()
Expand All @@ -168,7 +171,11 @@ type bridgeConn struct {
}

func (bc *bridgeConn) Close() {
bc.close()
<-bc.donec
}

func (bc *bridgeConn) close() {
bc.in.Close()
bc.out.Close()
<-bc.donec
}

0 comments on commit 998acd9

Please sign in to comment.