Skip to content

Commit

Permalink
dial timeout connection leak
Browse files Browse the repository at this point in the history
  • Loading branch information
soyum2222 committed Jan 4, 2021
1 parent f48726c commit 4c62663
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions headquarters.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ func Dial(addr string) (net.Conn, error) {

case <-func() chan struct{} {
ch := make(chan struct{})
_, err = sn.conn.Read(secondhand)
if err != nil {
c <- err
}

// here close is absolutely safe
close(ch)
go func() {
_, err = sn.conn.Read(secondhand)
if err != nil {
c <- err
}
close(ch)
}()

return ch
}():
Expand Down

0 comments on commit 4c62663

Please sign in to comment.