ソースを参照

Panic management

tags/0.9
9seconds 8年前
コミット
5b90e04185
1個のファイルの変更9行の追加3行の削除
  1. 9
    3
      proxy/server.go

+ 9
- 3
proxy/server.go ファイルの表示

@@ -51,10 +51,16 @@ func (s *Server) Addr() string {
51 51
 }
52 52
 
53 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 64
 	ctx, cancel := context.WithCancel(context.Background())
59 65
 	socketID := s.makeSocketID()
60 66
 

読み込み中…
キャンセル
保存