优化TCP源站错误提示

This commit is contained in:
刘祥超
2023-12-15 18:38:09 +08:00
parent c039691a71
commit 0f2068b161

View File

@@ -47,9 +47,13 @@ func (this *TCPListener) Serve() error {
atomic.AddInt64(&this.countActiveConnections, 1) atomic.AddInt64(&this.countActiveConnections, 1)
go func(conn net.Conn) { go func(conn net.Conn) {
err = this.handleConn(conn) var server = this.Group.FirstServer()
if server == nil {
return
}
err = this.handleConn(server, conn)
if err != nil { if err != nil {
remotelogs.Error("TCP_LISTENER", err.Error()) remotelogs.ServerError(server.Id, "TCP_LISTENER", err.Error(), "", nil)
} }
atomic.AddInt64(&this.countActiveConnections, -1) atomic.AddInt64(&this.countActiveConnections, -1)
}(conn) }(conn)
@@ -63,8 +67,7 @@ func (this *TCPListener) Reload(group *serverconfigs.ServerAddressGroup) {
this.Reset() this.Reset()
} }
func (this *TCPListener) handleConn(conn net.Conn) error { func (this *TCPListener) handleConn(server *serverconfigs.ServerConfig, conn net.Conn) error {
var server = this.Group.FirstServer()
if server == nil { if server == nil {
return errors.New("no server available") return errors.New("no server available")
} }