Browse Source

use SingleReader on low end devices

pull/1269/head
Darien Raymond 6 years ago
parent
commit
5f8b64c646
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 13
      common/buf/io.go
  2. 23
      common/buf/io_highend.go
  3. 13
      common/buf/io_lowend.go

13
common/buf/io.go

@ -59,18 +59,7 @@ func NewReader(reader io.Reader) Reader {
return mr
}
if useReadv {
if sc, ok := reader.(syscall.Conn); ok {
rawConn, err := sc.SyscallConn()
if err != nil {
newError("failed to get sysconn").Base(err).WriteToLog()
} else {
return NewReadVReader(reader, rawConn)
}
}
}
return NewBytesToBufferReader(reader)
return newReaderPlatform(reader)
}
// NewWriter creates a new Writer.

23
common/buf/io_highend.go

@ -0,0 +1,23 @@
// +build 386 amd64 s390 s390x
package buf
import (
"io"
"syscall"
)
func newReaderPlatform(reader io.Reader) Reader {
if useReadv {
if sc, ok := reader.(syscall.Conn); ok {
rawConn, err := sc.SyscallConn()
if err != nil {
newError("failed to get sysconn").Base(err).WriteToLog()
} else {
return NewReadVReader(reader, rawConn)
}
}
}
return NewBytesToBufferReader(reader)
}

13
common/buf/io_lowend.go

@ -0,0 +1,13 @@
// +build mips mipsle mips64 mips64le arm arm64
package buf
import (
"io"
)
func newReaderPlatform(reader io.Reader) Reader {
return &SingleReader{
Reader: reader,
}
}
Loading…
Cancel
Save