From a501880b0aadedc68615539ad8c3dae89b672a8f Mon Sep 17 00:00:00 2001 From: Marek Schimara Date: Mon, 24 Oct 2016 13:11:24 +0200 Subject: [PATCH] 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. --- src/rrd_daemon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) */ -- 2.47.2