From a7af81c7d2369bd05a21f9e780dad0e54759c139 Mon Sep 17 00:00:00 2001 From: David Millar Date: Mon, 28 Oct 2024 11:38:15 -0500 Subject: [PATCH] Reconnect when read fails due to broken pipe. --- README.pod | 4 ++++ lib/Redis.pm | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.pod b/README.pod index de7999f..ff17bfb 100644 --- a/README.pod +++ b/README.pod @@ -1619,6 +1619,10 @@ Ivan Kruglov Steffen Mueller +=item * + +David Millar + =back =head1 AUTHORS diff --git a/lib/Redis.pm b/lib/Redis.pm index 62bcb21..8c51293 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -28,6 +28,7 @@ use constant EWOULDBLOCK => eval {Errno::EWOULDBLOCK} || -1E9; use constant EAGAIN => eval {Errno::EAGAIN} || -1E9; use constant EINTR => eval {Errno::EINTR} || -1E9; use constant ECONNRESET => eval {Errno::ECONNRESET} || -1E9; +use constant EPIPE => eval {Errno::EPIPE} || -1E9; # According to IO::Socket::SSL documentation, 16k is the maximum # size of an SSL frame and because sysread returns data from only @@ -1038,6 +1039,9 @@ sub __try_read_sock { ## or because an intermediate proxy shut down our connection using its internal timeout counter return 0 if ($err && $err == ECONNRESET); + ## Broken pipe, we will need to reconnect + $self->__throw_reconnect('Broken pipe') if $err == EPIPE; + ## result is undef but err is 0? should never happen return if $err == 0;