Skip to content

Commit

Permalink
retry len check
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Nov 28, 2023
1 parent 80df767 commit 3bcdb55
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions connection_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,17 @@ func (c *connection) waitRead(n int) (err error) {
for c.inputBuffer.Len() < n {
switch c.status(closing) {
case poller:
return Exception(ErrConnClosed, "wait read")
return Exception(ErrEOF, "wait read")
case user:
return Exception(ErrConnClosed, "wait read")
default:
err = <-c.readTrigger
if err != nil {
log.Printf("netpoll readTrigger get %v %v", err, c.status(closing))
//return err
log.Printf("netpoll readTrigger get %v %v %d", err, c.status(closing), c.inputBuffer.Len())
if c.inputBuffer.Len() < n {
return nil
}
return err
}
continue
}
Expand All @@ -434,7 +437,7 @@ func (c *connection) waitReadWithTimeout(n int) (err error) {
switch c.status(closing) {
case poller:
// cannot return directly, stop timer first!
err = Exception(ErrConnClosed, "wait read")
err = Exception(ErrEOF, "wait read")
goto RET
case user:
// cannot return directly, stop timer first!
Expand All @@ -450,8 +453,12 @@ func (c *connection) waitReadWithTimeout(n int) (err error) {
return Exception(ErrReadTimeout, c.remoteAddr.String())
case err = <-c.readTrigger:
if err != nil {
log.Printf("netpoll readTrigger get %v %v", err, c.status(closing))
//return err
log.Printf("netpoll readTrigger get %v %v %d", err, c.status(closing), c.inputBuffer.Len())
// double check if there is enough data to be read
if c.inputBuffer.Len() >= n {
goto RET
}
return err
}
continue
}
Expand Down

0 comments on commit 3bcdb55

Please sign in to comment.