Skip to content

Commit

Permalink
fix(zipper): continue when listener accepts an error (#957)
Browse files Browse the repository at this point in the history
When an error occurs while the server is accepting a connection, the
service should not exit as it could be due to client-side reasons.
  • Loading branch information
woorui authored Dec 14, 2024
1 parent ca0e0cf commit 40b0952
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,16 @@ func (s *Server) Serve(ctx context.Context, conn net.PacketConn) error {

defer closeServer(s.downstreams, s.connector, s.listener, s.router)

errCount := 0
for {
fconn, err := s.listener.Accept(s.ctx)
if err != nil {
if err == s.ctx.Err() {
return ErrServerClosed
}
s.logger.Error("accepted an error when accepting a connection", "err", err)
return err
errCount++
s.logger.Error("accepted an error when accepting a connection", "err", err, "err_count", errCount)
continue
}

go s.handleFrameConn(fconn, s.logger)
Expand Down

0 comments on commit 40b0952

Please sign in to comment.