Explorar el Código

Panic management

tags/0.9
9seconds hace 8 años
padre
commit
5b90e04185
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9
    3
      proxy/server.go

+ 9
- 3
proxy/server.go Ver fichero

51
 }
51
 }
52
 
52
 
53
 func (s *Server) accept(conn net.Conn) {
53
 func (s *Server) accept(conn net.Conn) {
54
-	defer conn.Close()
55
-	defer s.stats.closeConnection()
56
-	s.stats.newConnection()
54
+	defer func() {
55
+		s.stats.closeConnection()
56
+		conn.Close()
57
+
58
+		if r := recover(); r != nil {
59
+			s.logger.Errorw("Crash of accept handler", "error", r)
60
+		}
61
+	}()
57
 
62
 
63
+	s.stats.newConnection()
58
 	ctx, cancel := context.WithCancel(context.Background())
64
 	ctx, cancel := context.WithCancel(context.Background())
59
 	socketID := s.makeSocketID()
65
 	socketID := s.makeSocketID()
60
 
66
 

Loading…
Cancelar
Guardar