lrstanley / girc

:bomb: girc is a flexible IRC library for Go :ok_hand:
https://pkg.go.dev/github.com/lrstanley/girc
MIT License
137 stars 13 forks source link

Don't check for timeout before sending first PING #56

Closed nmeum closed 2 years ago

nmeum commented 2 years ago

While debugging the problem described in https://github.com/lrstanley/girc/issues/50#issuecomment-1153145075 further I noticed that they seem to be some edge cases where the pingLoop exits with a timeout before the first PING message is sent. This causes PING timeouts very shortly after reconnecting, for example:

2022-06-07_21:51:47.09441 hii.go:769: timed out waiting for a requested PING response
2022-06-07_22:54:57.25356 hii.go:769: timed out waiting for a requested PING response
2022-06-07_22:56:27.37343 hii.go:769: timed out waiting for a requested PING response
2022-06-07_22:57:57.46345 hii.go:769: timed out waiting for a requested PING response

Looking at the pingLoop implementation, the timeout check is performed before the PING message is sent. This commit adds such a check as an additional safeguard thereby not only relying on timing.

yunginnanet commented 2 years ago

Big ups, player