Skip to content

Commit

Permalink
io func return n==0
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Feb 15, 2023
1 parent f7ff4b4 commit 5996a2d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ package netpoll
import "syscall"

// return value:
// - n: n < 0 but err == nil, retry syscall
// - n: n == 0 but err == nil, retry syscall
// - err: if not nil, connection should be closed.
func ioread(fd int, bs [][]byte, ivs []syscall.Iovec) (n int, err error) {
n, err = readv(fd, bs, ivs)
if n == 0 && err == nil { // means EOF
return -1, Exception(ErrEOF, "")
return 0, Exception(ErrEOF, "")
}
if err == syscall.EINTR || err == syscall.EAGAIN {
return -1, nil
return 0, nil
}
return n, err
}

// return value:
// - n: n < 0 but err == nil, retry syscall
// - n: n == 0 but err == nil, retry syscall
// - err: if not nil, connection should be closed.
func iosend(fd int, bs [][]byte, ivs []syscall.Iovec, zerocopy bool) (n int, err error) {
n, err = sendmsg(fd, bs, ivs, zerocopy)
if err == syscall.EAGAIN {
return -1, nil
return 0, nil
}
return n, err
}

0 comments on commit 5996a2d

Please sign in to comment.