perl-redis
perl-redis copied to clipboard
Redis connect() does not correctly handle Interrupted System Call (EINTR)
We have noticed that on busy systems we very occasionally see redis failure to connect due to the connect system call getting interrupted via EINTR
.
Probably the solution is something like this:
diff --git a/lib/Redis.pm b/lib/Redis.pm
index b3faa06..994af04 100644
--- a/lib/Redis.pm
+++ b/lib/Redis.pm
@@ -661,8 +661,13 @@ sub connect {
sub __build_sock {
my ($self) = @_;
- $self->{sock} = $self->{builder}->($self)
- || croak("Could not connect to Redis server at $self->{server}: $!");
+ do {
+ $self->{sock} = $self->{builder}->($self)
+ } while (!$self->{sock} && $! == Errno::EINTR);
+
+ unless ($self->{sock}) {
+ croak("Could not connect to Redis server at $self->{server}: $!");
+ }
$self->{__buf} = '';