mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 13:54:02 +03:00
Panic management
This commit is contained in:
+9
-3
@@ -51,10 +51,16 @@ func (s *Server) Addr() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) accept(conn net.Conn) {
|
func (s *Server) accept(conn net.Conn) {
|
||||||
defer conn.Close()
|
defer func() {
|
||||||
defer s.stats.closeConnection()
|
s.stats.closeConnection()
|
||||||
s.stats.newConnection()
|
conn.Close()
|
||||||
|
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
s.logger.Errorw("Crash of accept handler", "error", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
s.stats.newConnection()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
socketID := s.makeSocketID()
|
socketID := s.makeSocketID()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user