diff --git a/server.go b/server.go index 376883d..2c86b89 100644 --- a/server.go +++ b/server.go @@ -309,9 +309,6 @@ func (s *Server) handleSinglePacket(frisbeeConn *Async, connCtx context.Context) s.onClosed(frisbeeConn, err) return } - if s.ConnContext != nil { - connCtx = s.ConnContext(connCtx, frisbeeConn) - } for { handlerFunc = s.handlerTable[p.Metadata.Operation] if handlerFunc != nil { @@ -361,9 +358,6 @@ func (s *Server) handleUnlimitedPacket(frisbeeConn *Async, connCtx context.Conte s.onClosed(frisbeeConn, err) return } - if s.ConnContext != nil { - connCtx = s.ConnContext(connCtx, frisbeeConn) - } wg := new(sync.WaitGroup) closed := atomic.NewBool(false) connCtx, cancel := context.WithCancel(connCtx) @@ -391,9 +385,6 @@ func (s *Server) handleLimitedPacket(frisbeeConn *Async, connCtx context.Context s.onClosed(frisbeeConn, err) return } - if s.ConnContext != nil { - connCtx = s.ConnContext(connCtx, frisbeeConn) - } wg := new(sync.WaitGroup) closed := atomic.NewBool(false) connCtx, cancel := context.WithCancel(connCtx) @@ -465,6 +456,9 @@ func (s *Server) serveConn(newConn net.Conn) { } s.connections[frisbeeConn] = struct{}{} s.connectionsMu.Unlock() + if s.ConnContext != nil { + connCtx = s.ConnContext(connCtx, frisbeeConn) + } if s.concurrency == 0 { s.handleUnlimitedPacket(frisbeeConn, connCtx) } else if s.concurrency == 1 {