-#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
- first though. This will not be all that fast, but 'good' data
- like other rrdfiles headers will stay in cache. Now this only works if creating
- 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));
- fclose(rrd_file);
- return (-1);
+ /* flush all we don't need out of the cache */
+ rrd_init(&rrd_dn);
+ if((rrd_file_dn = rrd_open(file_name, &rrd_dn, RRD_READONLY)) != NULL)
+ {
+ rrd_dontneed(rrd_file_dn, &rrd_dn);
+ /* rrd_free(&rrd_dn); */
+ rrd_close(rrd_file_dn);