Skip to content

Commit

Permalink
Uses timer pool in sendNoWait, like in waitForSendErr
Browse files Browse the repository at this point in the history
  • Loading branch information
Preetha Appan committed Dec 19, 2017
1 parent b602ade commit 41ae2d8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,13 @@ func (s *Session) waitForSendErr(hdr header, body io.Reader, errCh chan error) e
// the send happens right here, we enforce the connection write timeout if we
// can't queue the header to be sent.
func (s *Session) sendNoWait(hdr header) error {
timer := time.NewTimer(s.config.ConnectionWriteTimeout)
defer timer.Stop()
t := timerPool.Get()
timer := t.(*time.Timer)
timer.Reset(s.config.ConnectionWriteTimeout)
defer func() {
timer.Stop()
timerPool.Put(t)
}()

select {
case s.sendCh <- sendReady{Hdr: hdr}:
Expand Down

0 comments on commit 41ae2d8

Please sign in to comment.