From: Marek Schimara Date: Mon, 24 Oct 2016 11:11:24 +0000 (+0200) Subject: src/rrd_daemon.c: fix incorrect line number reporting by rrdcached in fetch X-Git-Tag: v1.7.0~25^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F752%2Fhead;p=thirdparty%2Frrdtool-1.x.git src/rrd_daemon.c: fix incorrect line number reporting by rrdcached in fetch Example of error: rrdtool fetch --daemon 127.0.0.1:42218 .rrd --start -5min LAST ERROR: rrdc_fetch: Got 34 lines, expected 37 While the same, without '--daemon
' 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. --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index db548e78..70eee2dc 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -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) */