1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

use SingleReader on low end devices

This commit is contained in:
Darien Raymond 2018-08-17 11:52:55 +02:00
parent f056ad1633
commit 5f8b64c646
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 37 additions and 12 deletions

View File

@ -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 Normal file
View File

@ -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 Normal file
View File

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