Skip to content

Commit

Permalink
fix: Call ConnContext before reading first packet
Browse files Browse the repository at this point in the history
  • Loading branch information
pojntfx committed Oct 14, 2023
1 parent 870bd1d commit fe588a8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit fe588a8

Please sign in to comment.