From b0886027f51d9c585bc50d573c84dde1cd94603e Mon Sep 17 00:00:00 2001 From: Arthur Morgan <4637240+badO1a5A90@users.noreply.github.com> Date: Thu, 23 Sep 2021 11:37:46 +0800 Subject: [PATCH] Fix statistics error when not readV (#730) --- common/buf/io.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/buf/io.go b/common/buf/io.go index a1d4a861..b2d80ba2 100644 --- a/common/buf/io.go +++ b/common/buf/io.go @@ -71,17 +71,17 @@ func NewReader(reader io.Reader) Reader { _, isFile := reader.(*os.File) if !isFile && useReadv { - var counter stats.Counter - - if statConn, ok := reader.(*stat.CounterConnection); ok { - reader = statConn.Connection - counter = statConn.ReadCounter - } if sc, ok := reader.(syscall.Conn); ok { rawConn, err := sc.SyscallConn() if err != nil { newError("failed to get sysconn").Base(err).WriteToLog() } else { + var counter stats.Counter + + if statConn, ok := reader.(*stat.CounterConnection); ok { + reader = statConn.Connection + counter = statConn.ReadCounter + } return NewReadVReader(reader, rawConn, counter) } }