Skip to content

Commit

Permalink
fix: s.concurrency stays 0 when you don't use s.ServeConn
Browse files Browse the repository at this point in the history
Signed-off-by: Kirill Danshin <kirill@danshin.pro>
  • Loading branch information
kirillDanshin committed Apr 18, 2020
1 parent db18810 commit cc40779
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1888,8 +1888,14 @@ func (s *Server) idleTimeout() time.Duration {
return s.ReadTimeout
}

func (s *Server) serveConnCleanup() {
atomic.AddInt32(&s.open, -1)
atomic.AddUint32(&s.concurrency, ^uint32(0))
}

func (s *Server) serveConn(c net.Conn) (err error) {
defer atomic.AddInt32(&s.open, -1)
defer s.serveConnCleanup()
atomic.AddUint32(&s.concurrency, 1)

var proto string
if proto, err = s.getNextProto(c); err != nil {
Expand Down

0 comments on commit cc40779

Please sign in to comment.