Ticket #118 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

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

Reported by: human Owned by: oetiker
Priority: major Milestone:
Component: misc Version: 1.3dev
Keywords: Cc: bernard@…

Description

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.

Change History

comment:1 Changed 4 years ago by oetiker

  • Status changed from new to closed
  • Resolution set to fixed

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;
-       $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";
       }
Note: See TracTickets for help on using tickets.

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.