oetiker / rrdtool-1.x

RRDtool 1.x - Round Robin Database
http://www.rrdtool.org
GNU General Public License v2.0
1.01k stars 263 forks source link

RRDp.pm does not return when error_mode is 'catch' and an error occurs #118

Closed oetiker closed 12 years ago

oetiker commented 12 years ago

There is a problem in source:trunk/program/bindings/perl-piped/RRDp.pm when the '''error_mode''' is set to '''catch''' and an error occurs.

Since the behaviour of rrdtool in pipe mode describes the result of a command being one of two things

  1. '''OK''' followed by the timings
  2. '''ERROR''' followed by a relevant string

the RRDp needs to take into account that the read sequence is complete in either case.

Unfortunately the '''ERROR''' case returns to the read loop rather than returning. A simple {{{ return undef; }}} within the ERROR block should suffice, though I am not sure whether the timing variables should also be unset to avoid inappropriate use.

oetiker commented 12 years ago

[oetiker] Try this:

{{{ --- RRDp.pm (revision 1199) +++ RRDp.pm (working copy) @@ -163,11 +163,14 @@ $RRDp::error = undef; if ($line =~ m|^ERROR|) { $RRDp::error_mode eq 'catch' ? $RRDp::error = $line : croak $line;