From cc407796cd93d765edb57bd687afeec70920f522 Mon Sep 17 00:00:00 2001 From: Kirill Danshin Date: Thu, 16 Apr 2020 22:47:01 +0300 Subject: [PATCH] fix: s.concurrency stays 0 when you don't use s.ServeConn Signed-off-by: Kirill Danshin --- server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 43a4507..34e6f43 100644 --- a/server.go +++ b/server.go @@ -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 {