Skip to content

Commit 0691077

Browse files
committed
fix deadlock preventing activityTimer reset
attempting to drain an already drained timer causes a deadlock and prevents activityTimer from being reset therefore heartbeat pings are not periodically sent. Issue documented here: golang/go#27169
1 parent 45179f6 commit 0691077

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

client.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ func (c *Client) heartbeat() {
188188
select {
189189
case <-c.activityTimerReset:
190190
if !c.activityTimer.Stop() {
191-
<-c.activityTimer.C
191+
{
192+
select {
193+
case <-c.activityTimer.C:
194+
default:
195+
}
196+
}
192197
}
193198
c.activityTimer.Reset(c.activityTimeout)
194199

0 commit comments

Comments
 (0)