Skip to content

Commit

Permalink
check deadline before sendMsg, because select is randomly, sometimes …
Browse files Browse the repository at this point in the history
…it will write successfully after deadline

Signed-off-by: Asutorufa <[email protected]>
  • Loading branch information
Asutorufa committed Dec 13, 2023
1 parent 828214b commit a773ffa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ func (s *Session) sendMsg(hdr header, body []byte, deadline <-chan struct{}) err
default:
}

select {
case <-deadline:
return ErrTimeout

Check warning on line 495 in session.go

View check run for this annotation

Codecov / codecov/patch

session.go#L494-L495

Added lines #L494 - L495 were not covered by tests
default:
}

// duplicate as we're sending this async.
buf := pool.Get(headerSize + len(body))
copy(buf[:headerSize], hdr[:])
Expand Down

0 comments on commit a773ffa

Please sign in to comment.