Code

now the fadvise code actually compiles ... let the testing begin.
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Thu, 17 May 2007 11:38:54 +0000 (11:38 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Thu, 17 May 2007 11:38:54 +0000 (11:38 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1064 a5681a0c-68f1-0310-ab6d-d61299d08faa

configure.ac
src/rrd_create.c
src/rrd_fetch.c
src/rrd_open.c
src/rrd_update.c

index 8e64c11a93831303510248901aa37838b6bc4c7f..f878dccd3ae5eddeab90b07be6902e4749b8005c 100644 (file)
@@ -71,7 +71,8 @@ char *strchr (), *strrchr ();
 #endif
 
 /* enable posix_fadvise on linux */
-#ifdef HAVE_POSIX_FADVISE
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H)
+#include <fcntl.h>
 #define __USE_XOPEN2K 1
 #endif
 
index 521c72611488f1c4e5fc68d28d357ac94b6e0fab..6f4c8043da656128e2adc2be9971c54edf6a8227 100644 (file)
@@ -690,7 +690,7 @@ rrd_create_fn(const char *file_name, rrd_t *rrd)
        return(-1);
     }
     
-#ifdef POSIX_FADVISE
+#ifdef HAVE_POSIX_FADVISE
     /* this file is not going to be read again any time
        soon, so we drop everything except the header portion from
        the buffer cache. for this to work, we have to fdsync the file
index 7e92c2caeadb1cf42ac9c026bf1dc586c82e1668..0676b4ac3102172a894359e787ffe338574755ff 100644 (file)
@@ -456,11 +456,11 @@ fprintf(stderr,"partial match, not best\n");
                fclose(in_file);
                return(-1);
            }
-#ifdef POSIX_FADVISE
+#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)) {
-           rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno));
+           rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno));
            fclose(in_file);
            return(-1);
        } 
@@ -480,10 +480,10 @@ fprintf(stderr,"partial match, not best\n");
        
     }
     rrd_free(&rrd);
-#ifdef POSIX_FADVISE
+#ifdef HAVE_POSIX_FADVISE
     /* and just to be sure we drop everything except the header at the end */
     if (0 != posix_fadvise(fileno(in_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) {
-           rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno));
+           rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno));
            fclose(in_file);
            return(-1);
     } 
index 8f08176494fe48f01b6f889f491a28209096603a..3740750fb73e6839ead4d5c7a13a54e02547ad1c 100644 (file)
@@ -88,7 +88,7 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr)
         return (-1);
     }
 
-#ifdef POSIX_FADVISE
+#ifdef HAVE_POSIX_FADVISE
     /* In general we need no read-ahead when dealing with rrd_files.
        When we stop reading, it is highly unlikely that we start up again.
        In this manner we actually save time and diskaccess (and buffer cache).
index dc1a492bfdfeeba8139f8497f48c5454718b54c2..91a1d1bf53f98c82e0a454f4fe22a0f816321dc5 100644 (file)
@@ -1398,16 +1398,16 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv
        fclose(rrd_file);
        return(-1);
     }
-#ifdef POSIX_FADVISE
+#ifdef HAVE_POSIX_FADVISE
 
     /* 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
        will let the data off the hook as soon as it is written when if it is from a previous
        update cycle. Calling fdsync to force things is much too hard here. */
 
-    if (0 != posix_fadvise(fileno(in_file), rra_begin, 0, POSIX_FADV_DONTNEED)) {
-         rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno));
-         fclose(in_file);
+    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));
+         fclose(rrd_file);
          return(-1);
     } 
 #endif
@@ -1449,11 +1449,11 @@ _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 POSIX_FADVISE
+#ifdef HAVE_POSIX_FADVISE
           /* same procedure as above ... */
-          if (0 != posix_fadvise(fileno(in_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) {
-             rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno));
-             fclose(in_file);
+          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));
+             fclose(rrd_file);
              return(-1);
           } 
 #endif