From 232e715b8b70adc148a893a84ae806c26e377687 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 25 Jul 2018 11:19:16 +0200 Subject: [PATCH] don't build readv for windows --- common/buf/io.go | 13 ------------- common/buf/readv_reader.go | 14 ++++++++++++++ common/buf/readv_reader_windows.go | 13 +++++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 common/buf/readv_reader_windows.go diff --git a/common/buf/io.go b/common/buf/io.go index 737bd355e..37e739fac 100644 --- a/common/buf/io.go +++ b/common/buf/io.go @@ -2,11 +2,8 @@ package buf import ( "io" - "runtime" "syscall" "time" - - "v2ray.com/core/common/platform" ) // Reader extends io.Reader with MultiBuffer. @@ -50,16 +47,6 @@ func ReadAtLeastFrom(reader io.Reader, size int) Supplier { } } -var useReadv = false - -func init() { - const defaultFlagValue = "NOT_DEFINED_AT_ALL" - value := platform.NewEnvFlag("v2ray.buf.readv").GetValue(func() string { return defaultFlagValue }) - if value != defaultFlagValue && (runtime.GOOS == "linux" || runtime.GOOS == "darwin") { - useReadv = true - } -} - // NewReader creates a new Reader. // The Reader instance doesn't take the ownership of reader. func NewReader(reader io.Reader) Reader { diff --git a/common/buf/readv_reader.go b/common/buf/readv_reader.go index 989dcd92e..d29741873 100644 --- a/common/buf/readv_reader.go +++ b/common/buf/readv_reader.go @@ -1,9 +1,13 @@ +// +build !windows package buf import ( "io" + "runtime" "syscall" "unsafe" + + "v2ray.com/core/common/platform" ) type ReadVReader struct { @@ -96,3 +100,13 @@ func (r *ReadVReader) ReadMultiBuffer() (MultiBuffer, error) { return MultiBuffer(bs[:nBuf]), nil } + +var useReadv = false + +func init() { + const defaultFlagValue = "NOT_DEFINED_AT_ALL" + value := platform.NewEnvFlag("v2ray.buf.readv").GetValue(func() string { return defaultFlagValue }) + if value != defaultFlagValue && (runtime.GOOS == "linux" || runtime.GOOS == "darwin") { + useReadv = true + } +} diff --git a/common/buf/readv_reader_windows.go b/common/buf/readv_reader_windows.go new file mode 100644 index 000000000..a55b6c754 --- /dev/null +++ b/common/buf/readv_reader_windows.go @@ -0,0 +1,13 @@ +// +build windows +package buf + +import ( + "io" + "syscall" +) + +var useReadv = false + +func NewReadVReader(reader io.Reader, rawConn syscall.RawConn) *ReadVReader { + return nil +}