miyagawa / AnyEvent-Redis

Asynchronous Redis client
http://search.cpan.org/dist/AnyEvent-Redis
41 stars 16 forks source link

cleanup on connection failure #3

Closed leedo closed 14 years ago

leedo commented 14 years ago

I've noticed some issues that are caused by shutting down or restarting my redis server.

If I run a command and it fails due to a broken connection it eventually starts to hang on new commands. On the next immediate command tcp_connect fails due to the unset $fh variable. But anything after does nothing. I think this is because $self->{sock} and $self->{run_cb} are still set after the failed connection, so it doesn't attempt to connect again.

Running $self->cleanup in the connection failure block seems to fix this issue, with the added bonus of getting $self->{on_error} called when a connection fails.

miyagawa commented 14 years ago

Thanks, merged.