Skip to content

Commit

Permalink
Merge pull request #622 from tomatod/fix_panic_when_keepalive_zero
Browse files Browse the repository at this point in the history
Resolve panic when keep alive is set to 1 (second)

#closes 531
  • Loading branch information
MattBrittan committed Dec 21, 2022
2 parents a1800d8 + a0e4e11 commit d9dea69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ping.go
Expand Up @@ -32,16 +32,16 @@ import (
func keepalive(c *client, conn io.Writer) {
defer c.workers.Done()
DEBUG.Println(PNG, "keepalive starting")
var checkInterval int64
var checkInterval time.Duration
var pingSent time.Time

if c.options.KeepAlive > 10 {
checkInterval = 5
checkInterval = 5 * time.Second
} else {
checkInterval = c.options.KeepAlive / 2
checkInterval = time.Duration(c.options.KeepAlive) * time.Second / 2
}

intervalTicker := time.NewTicker(time.Duration(checkInterval * int64(time.Second)))
intervalTicker := time.NewTicker(checkInterval)
defer intervalTicker.Stop()

for {
Expand Down

0 comments on commit d9dea69

Please sign in to comment.