From: Tobias Oetiker Date: Sun, 4 Nov 2007 21:56:19 +0000 (+0000) Subject: handle errors properly ... in RRDp read call X-Git-Tag: 1.3rc2~88 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=118356aa752045dece15ac97847e0cfd2453c4e7;p=thirdparty%2Frrdtool-1.x.git handle errors properly ... in RRDp read call git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1209 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/bindings/perl-piped/RRDp.pm b/bindings/perl-piped/RRDp.pm index 3601cdd4..91facb3f 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"; }