Przeglądaj źródła

Panic management

tags/0.9
9seconds 8 lat temu
rodzic
commit
5b90e04185
1 zmienionych plików z 9 dodań i 3 usunięć
  1. 9
    3
      proxy/server.go

+ 9
- 3
proxy/server.go Wyświetl plik

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
 

Ładowanie…
Anuluj
Zapisz