Skip to content

Commit 9e086cb

Browse files
committed
Fix connection leaks.
1 parent b7fde80 commit 9e086cb

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ func (ctx *DevProxy) bidiTunnel(connA net.Conn, connB net.Conn) {
9595
wg := &sync.WaitGroup{}
9696
wg.Add(1)
9797
go func() {
98+
defer wg.Done()
9899
ctx.unidiTunnel(connA, connB)
99100
connA.SetDeadline(time.Unix(0, 0))
100101
connB.SetDeadline(time.Unix(0, 0))
101102
}()
102103
wg.Add(1)
103104
go func() {
105+
defer wg.Done()
104106
ctx.unidiTunnel(connB, connA)
105107
connA.SetDeadline(time.Unix(0, 0))
106108
connB.SetDeadline(time.Unix(0, 0))

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ func (proxyCtx *OurProxyCtx) DoRequest(req *http.Request, respW http.ResponseWri
363363
}
364364

365365
func (proxyCtx *OurProxyCtx) HandleConnect(r *http.Request, proxyClient net.Conn) {
366+
defer proxyClient.Close()
366367
var targetHostPort string
367368
{
368369
pair := splitHostPort(r.URL.Host)

0 commit comments

Comments
 (0)