From 2f5b448d06ee09e4153a6dcf865a258228171e7b Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 8 Jul 2010 14:31:46 +0000 Subject: [PATCH] instead of reading the MARC data directly from the socket, set the end-of-line character appropriately and read the data directly from STDIN. The 'wait' time is now only used as a security measure to prevent accidental hogging of worker processes git-svn-id: svn://svn.open-ils.org/ILS/trunk@16879 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/support-scripts/marc_stream_importer.pl | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_stream_importer.pl b/Open-ILS/src/support-scripts/marc_stream_importer.pl index 60ba74157..26b180b37 100755 --- a/Open-ILS/src/support-scripts/marc_stream_importer.pl +++ b/Open-ILS/src/support-scripts/marc_stream_importer.pl @@ -321,20 +321,15 @@ sub process_batch_data { } sub process_request { # The core Net::Server method - my $self = shift; - my $socket = $self->{server}->{client}; - my $data = ''; - my $buf; - - # Reading blocks until the client is closed. Instead of waiting - # for that, give each inbound record $wait_time seconds to fully arrive - # and pull the data directly from the socket + local $/ = "\x1D"; # MARC record separator + $logger->info("stream parser received contact"); + my $data; eval { - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm $wait_time; - $data .= $buf while $socket->sysread($buf, $bufsize); + alarm $wait_time; # prevent accidental tie ups of backend processes + $data = ; alarm 0; }; + $logger->info("stream parser read " . length($data) . " bytes"); if ($real_opts->{noqueue}) { old_process_batch_data($data); } else { -- 2.11.0