PerlRedis/perl-redis — pull request #57 by tjamesking (2013-10-25 19:56:32+00:00)
Title: fix connect timeout

The socket builder does not specify a timeout for IO::Socket::INET->new,
so the system timeout gets used for connect() calls. This is not a problem
for explicitly rejected connection attempts, but causes excessively long
timeouts when no TCP reset is received (e.g. silent ACL drop or host down).

On Linux, the default value of /proc/sys/net/tcp_syn_retries means a single
connect() will take more than 3 minutes to timeout in this scenario, causing
only a single attempt to be made and making the "every" parameter
effectively useless.

Set a timeout in the socket builder based on "every", and make the usleep()
in __connect() conditional in order to handle both cases properly.