summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44f4a54)
raw | patch | inline | side by side (parent: 44f4a54)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 13 Nov 2007 02:16:10 +0000 (02:16 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 13 Nov 2007 02:16:10 +0000 (02:16 +0000) |
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1216 a5681a0c-68f1-0310-ab6d-d61299d08faa
src/rrd_create.c | patch | blob | history |
diff --git a/src/rrd_create.c b/src/rrd_create.c
index 16bde5bcad222742bb95c4ed937f22c9def65687..127666afb55e44bd36273bac9d3424db02ec4c61 100644 (file)
--- a/src/rrd_create.c
+++ b/src/rrd_create.c
FILE *rrd_file;
rrd_value_t *unknown;
int unkn_cnt;
-
- long rrd_head_size;
-
+
if ((rrd_file = fopen(file_name,"wb")) == NULL ) {
rrd_set_error("creating '%s': %s",file_name, rrd_strerror(errno));
- rrd_free(rrd);
+ rrd_free(rrd);
return(-1);
}
rrd->rra_ptr->cur_row = rrd->rra_def[i].row_cnt - 1;
fwrite( rrd->rra_ptr, sizeof(rra_ptr_t),1,rrd_file);
}
- rrd_head_size = ftell(rrd_file);
-
+
/* write the empty data area */
if ((unknown = (rrd_value_t *)malloc(512 * sizeof(rrd_value_t))) == NULL) {
rrd_set_error("allocating unknown");
return(-1);
}
-#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);
- }
-#endif
-
fclose(rrd_file);
rrd_free(rrd);
return (0);