Fix statistics error when not readV (#730)

This commit is contained in:
Arthur Morgan 2021-09-23 11:37:46 +08:00 committed by GitHub
parent 7033f7cf5f
commit b0886027f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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