From 0f2068b1617b5f8e04b3f510bd1ccec0e23018b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Fri, 15 Dec 2023 18:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96TCP=E6=BA=90=E7=AB=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/listener_tcp.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/nodes/listener_tcp.go b/internal/nodes/listener_tcp.go index 7ea7dee..5db0de6 100644 --- a/internal/nodes/listener_tcp.go +++ b/internal/nodes/listener_tcp.go @@ -47,9 +47,13 @@ func (this *TCPListener) Serve() error { atomic.AddInt64(&this.countActiveConnections, 1) 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 { - remotelogs.Error("TCP_LISTENER", err.Error()) + remotelogs.ServerError(server.Id, "TCP_LISTENER", err.Error(), "", nil) } atomic.AddInt64(&this.countActiveConnections, -1) }(conn) @@ -63,8 +67,7 @@ func (this *TCPListener) Reload(group *serverconfigs.ServerAddressGroup) { this.Reset() } -func (this *TCPListener) handleConn(conn net.Conn) error { - var server = this.Group.FirstServer() +func (this *TCPListener) handleConn(server *serverconfigs.ServerConfig, conn net.Conn) error { if server == nil { return errors.New("no server available") }