From a7be31f137ccf6e2f4522c9a4c690a23b5636db8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 28 Oct 2011 11:33:24 -0400 Subject: [PATCH] Add SIGPIPE retry handling to child data sysread Similar to the SIGPIPE retry logic wrapped around the parent process' syswrite call (for sending data to a child process), protect the child's sysread call (as it reads data from the parent). In pre-2.0, the sysread step was handled by Net::Server, but now we need to protect it ourselves. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- src/perl/lib/OpenSRF/Server.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/perl/lib/OpenSRF/Server.pm b/src/perl/lib/OpenSRF/Server.pm index 28980d3..9e7ffa8 100644 --- a/src/perl/lib/OpenSRF/Server.pm +++ b/src/perl/lib/OpenSRF/Server.pm @@ -589,10 +589,20 @@ sub wait_for_request { while(1) { # Start out blocking, when data is available, read it all + my $sig_pipe = 0; + local $SIG{'PIPE'} = sub { $sig_pipe = 1 }; + my $buf = ''; my $n = sysread($self->{pipe_to_parent}, $buf, $read_size); unless(defined $n) { + + if ($sig_pipe) { + $logger->info("server: $self got SIGPIPE reading data from parent, retrying..."); + usleep(50000); # 50 msec + next; + } + $logger->error("server: error reading data pipe: $!") unless EAGAIN == $!; last; } -- 2.43.2