Skip to content

Commit

Permalink
check deadline before sending a message (#114)
Browse files Browse the repository at this point in the history
Signed-off-by: Asutorufa <16442314+Asutorufa@users.noreply.github.com>
  • Loading branch information
Asutorufa committed Dec 13, 2023
1 parent 828214b commit 4c58128
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
default:
}

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

0 comments on commit 4c58128

Please sign in to comment.