From 02775f087b761f2a03570032c978d8605fc70e48 Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Thu, 4 May 2023 16:05:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BD=93=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=88=B0eof=E4=BC=9A=E4=B8=A2=E6=8E=89=E6=9C=AC?= =?UTF-8?q?=E6=AC=A1=E8=AF=BB=E5=8F=96=E6=B6=88=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/connection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/connection.go b/core/connection.go index 97f6703..00e48aa 100644 --- a/core/connection.go +++ b/core/connection.go @@ -8,6 +8,7 @@ import ( "git.noahlan.cn/noahlan/nnet/scheduler" "git.noahlan.cn/noahlan/ntools-go/core/nlog" "git.noahlan.cn/noahlan/ntools-go/core/pool" + "io" "net" "sync/atomic" ) @@ -199,12 +200,11 @@ func (r *connection) read() { defer func() { _ = r.Close() }() - buf := make([]byte, 4096) for { n, err := r.conn.Read(buf) //nlog.Debugf("receive data %v", buf[:n]) - if err != nil { + if err != nil && err != io.EOF { nlog.Errorf("%s [readLoop] Read message error: %s, session will be closed immediately", r.ngin.logPrefix(), err.Error()) return