From 1556df93d408ca0263cf7ab0833e25ab56978648 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 4 Nov 2007 21:56:19 +0000 Subject: [PATCH] handle errors properly ... in RRDp read call git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1209 a5681a0c-68f1-0310-ab6d-d61299d08faa --- bindings/perl-piped/RRDp.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bindings/perl-piped/RRDp.pm b/bindings/perl-piped/RRDp.pm index 3601cdd..91facb3 100644 --- a/bindings/perl-piped/RRDp.pm +++ b/bindings/perl-piped/RRDp.pm @@ -146,7 +146,6 @@ sub read () { my $buffer; my $nfound; my $timeleft; - my $ERR = 0; vec($inmask,fileno(RRDreadHand),1) = 1; # setup select mask for Reader while (1) { my $rout; @@ -163,11 +162,14 @@ sub read () { $RRDp::error = undef; if ($line =~ m|^ERROR|) { $RRDp::error_mode eq 'catch' ? $RRDp::error = $line : croak $line; - $ERR = 1; + $RRDp::sys = undef; + $RRDp::user = undef; + $RRDp::real = undef; + return undef; } - elsif ($line =~ m|^OK u:([\d\.]+) s:([\d\.]+) r:([\d\.]+)|){ + elsif ($line =~ m|^OK(?: u:([\d\.]+) s:([\d\.]+) r:([\d\.]+))?|){ ($RRDp::sys,$RRDp::user,$RRDp::real)=($1,$2,$3); - return $ERR == 1 ? undef : \$buffer; + return \$buffer; } else { $buffer .= $line. "\n"; } -- 2.30.2