fix: 修复当读取到eof会丢掉本次读取消息的bug

main v0.5.2
NoahLan 2 years ago
parent 621db20ab1
commit 02775f087b

@ -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

Loading…
Cancel
Save