Skip to content

Commit

Permalink
fix: 修复执行syscall.SYS_READV系统调用包装函数readv时,读完数据后,又清空缓冲区的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryOracle committed Dec 6, 2023
1 parent 9707178 commit 6a53bae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sys_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ func readv(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
}
// syscall
r, _, e := syscall.RawSyscall(syscall.SYS_READV, uintptr(fd), uintptr(unsafe.Pointer(&ivs[0])), uintptr(iovLen))
resetIovecs(bs, ivs[:iovLen])
if e != 0 {
return int(r), syscall.Errno(e)
}
return int(r), nil
}

// TODO: read from sysconf(_SC_IOV_MAX)? The Linux default is
// 1024 and this seems conservative enough for now. Darwin's
// UIO_MAXIOV also seems to be 1024.
//
// 1024 and this seems conservative enough for now. Darwin's
// UIO_MAXIOV also seems to be 1024.
//
// iovecs limit length to 2GB(2^31)
func iovecs(bs [][]byte, ivs []syscall.Iovec) (iovLen int) {
totalLen := 0
Expand Down

0 comments on commit 6a53bae

Please sign in to comment.