]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_daemon.c: fix incorrect line number reporting by rrdcached in fetch 752/head
authorMarek Schimara <Marek.Schimara@bull.net>
Mon, 24 Oct 2016 11:11:24 +0000 (13:11 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Mon, 24 Oct 2016 11:44:12 +0000 (13:44 +0200)
  Example of error:
    rrdtool fetch --daemon 127.0.0.1:42218 <path to>.rrd --start -5min LAST
    ERROR: rrdc_fetch: Got 34 lines, expected 37

  While the same, without '--daemon <address>' works fine.

  The bug manifests itself when the last element of line to write falls
  within the last 10% of the length of 'char linebuf[1024]', ie between
  922 and 1023 bytes; in that case the '\n' at the end of the line is
  not written, and so not seen by count_lines(), wrong number of lines
  given in the daemon's response -> 'rrdtool fetch' errors out.

src/rrd_daemon.c

index db548e78f413f9cebd6ecbe30715ddfc3329ed47..70eee2dcfeb7ae99030454709467951a92788215 100644 (file)
@@ -1981,7 +1981,9 @@ static int handle_request_fetch (HANDLER_PROTO) /* {{{ */
        linebuf_fill = 0;
       }
     }
-    if (linebuf_fill>0) {
+
+    /* only print out a line if parsed something */
+    if (i > 0) {
       add_response_info (sock, "%s\n", linebuf);
     }
   } /* for (t) */