X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cmd_listval.c;h=fb45200a519801da29a823adba57a25ded5c263d;hb=e01209268a710341765879eb32412027fb60257d;hp=4ca9646de8155a71b1a2b076cabf9b74ef5de002;hpb=3bd6fcdfd20002eee1f1803460728449c0c98f86;p=collectd.git diff --git a/src/utils_cmd_listval.c b/src/utils_cmd_listval.c index 4ca9646d..fb45200a 100644 --- a/src/utils_cmd_listval.c +++ b/src/utils_cmd_listval.c @@ -39,18 +39,21 @@ } while (0) #define print_to_socket(fh, ...) \ - if (fprintf (fh, __VA_ARGS__) < 0) { \ - char errbuf[1024]; \ - WARNING ("handle_listval: failed to write to socket #%i: %s", \ - fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \ - free_everything_and_return (-1); \ - } + do { \ + if (fprintf (fh, __VA_ARGS__) < 0) { \ + char errbuf[1024]; \ + WARNING ("handle_listval: failed to write to socket #%i: %s", \ + fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \ + free_everything_and_return (-1); \ + } \ + fflush(fh); \ + } while (0) int handle_listval (FILE *fh, char *buffer) { char *command; char **names = NULL; - time_t *times = NULL; + cdtime_t *times = NULL; size_t number = 0; size_t i; int status; @@ -90,7 +93,8 @@ int handle_listval (FILE *fh, char *buffer) print_to_socket (fh, "%i Value%s found\n", (int) number, (number == 1) ? "" : "s"); for (i = 0; i < number; i++) - print_to_socket (fh, "%u %s\n", (unsigned int) times[i], names[i]); + print_to_socket (fh, "%.3f %s\n", CDTIME_T_TO_DOUBLE (times[i]), + names[i]); free_everything_and_return (0); } /* int handle_listval */