From bdd6eb6b84a917564d4b285d944adb62e1e5cebc 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@1065 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/configure.ac | 2 +- program/src/rrd_create.c | 1 + program/src/rrd_fetch.c | 2 +- program/src/rrd_update.c | 7 ++++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/program/configure.ac b/program/configure.ac index f878dccd..202f370a 100644 --- a/program/configure.ac +++ b/program/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/program/src/rrd_create.c b/program/src/rrd_create.c index 6f4c8043..e9ac860d 100644 --- a/program/src/rrd_create.c +++ b/program/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/program/src/rrd_fetch.c b/program/src/rrd_fetch.c index 0676b4ac..1b85edb1 100644 --- a/program/src/rrd_fetch.c +++ b/program/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/program/src/rrd_update.c b/program/src/rrd_update.c index 91a1d1bf..5f27c2f9 100644 --- a/program/src/rrd_update.c +++ b/program/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