MCPcopy
hub / github.com/aceld/zinx / finalizer

Method finalizer

znet/connection.go:510–539  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

508}
509
510func (c *Connection) finalizer() {
511 // Call the callback function registered by the user when closing the connection if it exists
512 // (如果用户注册了该连接的 关闭回调业务,那么在此刻应该显示调用)
513 c.callOnConnStop()
514
515 // Stop the heartbeat detector associated with the connection
516 if c.hc != nil {
517 c.hc.Stop()
518 }
519
520 // Close the socket connection
521 _ = c.conn.Close()
522
523 // Remove the connection from the connection manager
524 if c.connManager != nil {
525 c.connManager.Remove(c)
526 }
527
528 go func() {
529 defer func() {
530 if err := recover(); err != nil {
531 zlog.Ins().ErrorF("Conn finalizer panic: %v", err)
532 }
533 }()
534
535 c.InvokeCloseCallbacks()
536 }()
537
538 zlog.Ins().InfoF("Conn Stop()...ConnID = %d", c.connID)
539}
540
541func (c *Connection) callOnConnStart() {
542 if c.onConnStart != nil {

Callers 1

StartMethod · 0.95

Calls 8

callOnConnStopMethod · 0.95
InvokeCloseCallbacksMethod · 0.95
InsFunction · 0.92
CloseMethod · 0.80
StopMethod · 0.65
RemoveMethod · 0.65
ErrorFMethod · 0.65
InfoFMethod · 0.65

Tested by

no test coverage detected