浏览代码

Fix statistics error when not readV (#730)

Arthur Morgan 4 年之前
父节点
当前提交
b0886027f5
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      common/buf/io.go

+ 6 - 6
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)
 			}
 		}