[rrd-developers] [PATCH] journal_replay: detect eof failure in fgets() and break out.
Tobias Oetiker
tobi at oetiker.ch
Mon Sep 29 22:01:07 CEST 2008
Today kevin brintnall wrote:
> This bug caused the last line in each journal file to be processed a
> second time. Since it had been modified due to tokenizing, it failed
> syntax check. The daemon would always record one failed line at
> end-of-journal as a result. No data loss incurred by this bug.
thanks
tobi
>
> ---
> src/rrd_daemon.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
> index abcb788..ead969b 100644
> --- a/src/rrd_daemon.c
> +++ b/src/rrd_daemon.c
> @@ -1508,7 +1508,8 @@ static int journal_replay (const char *file) /* {{{ */
> size_t entry_len;
>
> ++line;
> - fgets(entry, sizeof(entry), fh);
> + if (fgets(entry, sizeof(entry), fh) == NULL)
> + break;
> entry_len = strlen(entry);
>
> /* check \n termination in case journal writing crashed mid-line */
>
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
More information about the rrd-developers
mailing list