Skip to content

Commit

Permalink
Fixed to avoid panic when keep alive is 0 #531.
Browse files Browse the repository at this point in the history
Signed-off-by: Daichi Tomaru <banaoa7543@gmail.com>
  • Loading branch information
tomatod committed Dec 20, 2022
1 parent a1800d8 commit e3b1fdd
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 e3b1fdd

Please sign in to comment.