Skip to content

Commit

Permalink
Remove the channel draining since it is not reused.
Browse files Browse the repository at this point in the history
Signed-off-by Daniele Vasselli <[email protected]>
  • Loading branch information
Daniele Vasselli committed Mar 21, 2024
1 parent d0120ee commit 8b638fb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,12 +799,10 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac
if publishWaitTimeout == 0 {
publishWaitTimeout = time.Second * 30
}

t := time.NewTimer(publishWaitTimeout)
defer func() {
if !t.Stop() {
<-t.C
}
}()
defer t.Stop()

select {
case c.obound <- &PacketAndToken{p: pub, t: token}:
case <-t.C:
Expand Down

0 comments on commit 8b638fb

Please sign in to comment.