(ctx context.Context)
| 122 | } |
| 123 | |
| 124 | func (s *Server) acceptLoop(ctx context.Context) { |
| 125 | defer s.wg.Done() |
| 126 | |
| 127 | for { |
| 128 | conn, err := s.listener.Accept() |
| 129 | if err != nil { |
| 130 | if ctx.Err() != nil { |
| 131 | s.logger.Warn(ctx, "accept loop terminated", slog.Error(ctx.Err())) |
| 132 | return |
| 133 | } |
| 134 | s.logger.Warn(ctx, "socket accept error", slog.Error(err)) |
| 135 | continue |
| 136 | } |
| 137 | |
| 138 | s.wg.Add(1) |
| 139 | go s.handleConnection(ctx, conn) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func (s *Server) handleConnection(ctx context.Context, conn net.Conn) { |
| 144 | defer s.wg.Done() |