From 9e72bd7d22cdb096abe35755a5dbcc5dc7686ee9 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 18 May 2007 11:56:34 +0000 Subject: [PATCH] * dropping in rrd_update is probably overkill since we may be dropping too much. * in create we have to flush before dropping. * read fcntl.h after defining the __USE_XOPEN2K * fix drop code in fetch ... git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1065 a5681a0c-68f1-0310-ab6d-d61299d08faa --- configure.ac | 2 +- src/rrd_create.c | 1 + src/rrd_fetch.c | 2 +- src/rrd_update.c | 7 ++++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index f878dcc..202f370 100644 --- a/configure.ac +++ b/configure.ac @@ -72,8 +72,8 @@ char *strchr (), *strrchr (); /* enable posix_fadvise on linux */ #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H) -#include #define __USE_XOPEN2K 1 +#include #endif #ifdef NO_NULL_REALLOC diff --git a/src/rrd_create.c b/src/rrd_create.c index 6f4c804..e9ac860 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -699,6 +699,7 @@ rrd_create_fn(const char *file_name, rrd_t *rrd) a single rrd file is not too large, but I assume this should not be the case in general. Otherwhise we would have to sync and release while writing all the unknown data. */ + fflush(rrd_file); fdatasync(fileno(rrd_file)); if (0 != posix_fadvise(fileno(rrd_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) { rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno)); diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c index 0676b4a..1b85edb 100644 --- a/src/rrd_fetch.c +++ b/src/rrd_fetch.c @@ -459,7 +459,7 @@ fprintf(stderr,"partial match, not best\n"); #ifdef HAVE_POSIX_FADVISE /* don't pollute the buffer cache with data read from the file. We do this while reading to keep damage minimal */ - if (0 != posix_fadvise(fileno(in_file), rrd_head_size, ftell(in_file), POSIX_FADV_DONTNEED)) { + if (0 != posix_fadvise(fileno(in_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) { rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); fclose(in_file); return(-1); diff --git a/src/rrd_update.c b/src/rrd_update.c index 91a1d1b..5f27c2f 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -1195,7 +1195,7 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv i < rrd.stat_head->rra_cnt; rra_start += rrd.rra_def[i].row_cnt * rrd.stat_head -> ds_cnt * sizeof(rrd_value_t), i++) { - /* is there anything to write for this RRA? If not, continue. */ + /* is th5Aere anything to write for this RRA? If not, continue. */ if (rra_step_cnt[i] == 0) continue; /* write the first row */ @@ -1398,7 +1398,8 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv fclose(rrd_file); return(-1); } -#ifdef HAVE_POSIX_FADVISE + +#ifdef HAVE_POSIX_FADVISExxx /* with update we have write ops, so they will probably not be done by now, this means the buffers will not get freed. But calling this for the whole file - header @@ -1449,7 +1450,7 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv rra_start += rrd.rra_def[i].row_cnt *rrd.stat_head->ds_cnt*sizeof(rrd_value_t); } -#ifdef HAVE_POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISExxx /* same procedure as above ... */ if (0 != posix_fadvise(fileno(rrd_file), rra_begin, 0, POSIX_FADV_DONTNEED)) { rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); -- 2.30.2