use the cached connection state
use the cached connection state

Like in ZK, do not call into the handle to get the state, instead just
return the state we cache anyway. This will prevent deadlocks when
things are trying to find out our state as we're closing.

Also change wait_until_connected to break if we go into @_shutting_down
or @_closed state, and be more accurate around the timeout value (treat
it as a deadline).

songling88/zookeeper,songling88/zookeeper,rickypai/zookeeper,zk-ruby/zookeeper,rickypai/zookeeper,rickypai/zookeeper,songling88/zookeeper,zk-ruby/zookeeper,songling88/zookeeper,rickypai/zookeeper,zk-ruby/zookeeper