Skip to content

Commit

Permalink
Merge pull request #115 from cloudwego/debug/fill_eof
Browse files Browse the repository at this point in the history
hotfix: fill.readv accurately check EOF
  • Loading branch information
Hchenn authored Feb 23, 2022
2 parents 10865ef + 58bbdba commit f670470
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions connection_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,23 @@ func (c *connection) fill(need int) (err error) {
for {
n, err = readv(c.fd, c.inputs(c.inputBarrier.bs), c.inputBarrier.ivs)
c.inputAck(n)
if n < pagesize || err != nil {
err = c.eofError(n, err)
if err != nil {
break
}
}
if c.inputBuffer.Len() >= need {
return nil
}
if err == nil {
err = Exception(ErrEOF, "")
return err
}

func (c *connection) eofError(n int, err error) error {
if err == syscall.EINTR {
return nil
}
if n == 0 && err == nil {
return Exception(ErrEOF, "")
}
return err
}

0 comments on commit f670470

Please sign in to comment.