BUG/MINOR: cli/stats: add missing trailing LF after "show info json"

This is the continuation of commit 5a0e7ca5d ("BUG/MINOR: cli/stats: add
missing trailing LF after JSON outputs"). There's also a "show info json"
command which was also missing the trailing LF. It's constructed exactly
like the "show stat json", in that it dumps a series of fields without any
LF. The difference however is that for the stats output, everything was
enclosed in an array which required an LF *after* the closing bracket,
while here there's no such array so we have to emit the LF after the loop.
That makes the two functions a bit inconsistent, it's quite annoying, but
making them better would require sending one LF per line in the stats
output, which is not particularly interesting.

Given that it took 5+ years to spot that this code wasn't working as
expected it doesn't seem worth investing much time trying to refactor
it to make it look cleaner at the risk of breaking other obscure parts.
This commit is contained in:
Willy Tarreau 2022-06-10 15:12:21 +02:00
parent 9b46fb4cca
commit c6b7a97e54

View File

@ -691,13 +691,13 @@ static int stats_dump_json_info_fields(struct buffer *out,
goto err;
}
if (!chunk_strcat(out, "]"))
if (!chunk_strcat(out, "]\n"))
goto err;
return 1;
err:
chunk_reset(out);
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}\n");
return 0;
}