bonifaido / rust-zookeeper

Pure Rust library for Apache ZooKeeper built on MIO
MIT License
206 stars 46 forks source link

Remove Poll::deregister call and improve reconnect logic #58

Closed davidwilemski closed 5 years ago

davidwilemski commented 5 years ago

This PR is intended to fix the panic seen in #56 and makes a few changes in the io module to that effect. The first is to remove the call to Poll::deregister as the Mio docs indicate that it should not be required (see comment in the issue mentioned above for link to docs). The second change is that any reads or writes that return 0 affected bytes should trigger a reconnect as the logging already notes that this means the connection has been lost. In a similar vein, if a read or write operation returns an io::error of ErrorKind::WouldBlock, we do not need to reconnect as it is a spurious wake up. Lastly, it seemed like we should be resetting the session timeout timer upon reconnect to avoid potential races where the reconnect happens and the session timeout timer fires before any operations can be made to prevent that timeout.