aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
531 stars 97 forks source link

Changed ping timeout logic in ping thread #54

Closed kcm1700 closed 8 years ago

kcm1700 commented 8 years ago

Previously, ping thread might enter infinite reconnect loop. Consider the following scenario.

  1. If at least one ping is sent, last_ping_data is updated.
  2. Then there are many activities, so should_ping() becomes false.
  3. After some seconds, now().to_timespec() - time > strong.ping_timeout_duration() is satisfied.
  4. reconnect()
  5. But should_ping() is still false.
  6. The condition is still satisfied, so reconnect() again and again.

I made several changes.

Followings are the changes in the code

Hopefully, this commit may be related to issue #50.

aatxe commented 8 years ago

Overall, looks good to me. I'll test whether or not this fixes #50. Thanks!