Skip to content

Commit

Permalink
move conngroup.Done() inside connection goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
lhridder committed Aug 23, 2022
1 parent cdfa028 commit d10172b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ func (gateway *Gateway) listenAndServe(listener Listener, addr string) error {

go func() {
gateway.conngroup.Add(1)
defer gateway.conngroup.Done()
if Config.Debug {
log.Printf("[>] Incoming %s on listener %s", conn.RemoteAddr(), addr)
}
Expand All @@ -333,12 +332,14 @@ func (gateway *Gateway) listenAndServe(listener Listener, addr string) error {
if Config.Debug {
log.Printf("[x] %s closed connection with %s; error: %s", conn.RemoteAddr(), addr, err)
}
gateway.conngroup.Done()
return
}
_ = conn.SetDeadline(time.Time{})
if Config.Debug {
log.Printf("[x] %s closed connection with %s", conn.RemoteAddr(), addr)
}
gateway.conngroup.Done()
}()
}
}
Expand Down

0 comments on commit d10172b

Please sign in to comment.