mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
fix windows reader
This commit is contained in:
parent
7c9c66601e
commit
b4d065610a
@ -2,7 +2,6 @@ package buf_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -51,7 +50,6 @@ func TestReadvReader(t *testing.T) {
|
|||||||
t.Fatal("unexpected error: ", err)
|
t.Fatal("unexpected error: ", err)
|
||||||
}
|
}
|
||||||
rmb.AppendMulti(mb)
|
rmb.AppendMulti(mb)
|
||||||
fmt.Println("Len=", rmb.Len())
|
|
||||||
if rmb.Len() == size {
|
if rmb.Len() == size {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
package buf
|
package buf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ func (r *windowsReader) Init(bs []*Buffer) {
|
|||||||
r.bufs = make([]syscall.WSABuf, 0, len(bs))
|
r.bufs = make([]syscall.WSABuf, 0, len(bs))
|
||||||
}
|
}
|
||||||
for _, b := range bs {
|
for _, b := range bs {
|
||||||
r.bufs = append(r.bufs, syscall.WSABuf{Len: uint32(b.Len()), Buf: &b.v[0]})
|
r.bufs = append(r.bufs, syscall.WSABuf{Len: uint32(Size), Buf: &b.v[0]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +31,6 @@ func (r *windowsReader) Read(fd uintptr) int32 {
|
|||||||
var flags uint32
|
var flags uint32
|
||||||
err := syscall.WSARecv(syscall.Handle(fd), &r.bufs[0], uint32(len(r.bufs)), &nBytes, &flags, nil, nil)
|
err := syscall.WSARecv(syscall.Handle(fd), &r.bufs[0], uint32(len(r.bufs)), &nBytes, &flags, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Err=", err)
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return int32(nBytes)
|
return int32(nBytes)
|
||||||
|
Loading…
Reference in New Issue
Block a user