summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9f3ebf)
raw | patch | inline | side by side (parent: e9f3ebf)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 25 May 2008 20:00:45 +0000 (20:00 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 25 May 2008 20:00:45 +0000 (20:00 +0000) |
src/rrd_format.h | patch | blob | history | |
src/rrd_open.c | patch | blob | history | |
src/rrd_update.c | patch | blob | history |
diff --git a/src/rrd_format.h b/src/rrd_format.h
index 9deb5abf1f862f632505af1389047f6f5e46ba7d..8539f0264cd8934936844e5e4a39c557ca875e72 100644 (file)
--- a/src/rrd_format.h
+++ b/src/rrd_format.h
stat_head_t *stat_head; /* the static header */
ds_def_t *ds_def; /* list of data source definitions */
rra_def_t *rra_def; /* list of round robin archive def */
- live_head_t *live_head;
+ live_head_t *live_head; /* rrd v >= 3 last_up with us */
+ time_t *legacy_last_up; /* rrd v < 3 last_up time */
pdp_prep_t *pdp_prep; /* pdp data prep area */
cdp_prep_t *cdp_prep; /* cdp prep area */
rra_ptr_t *rra_ptr; /* list of rra pointers */
diff --git a/src/rrd_open.c b/src/rrd_open.c
index b6f3abb52d1234fad9e7540c449a239dd533903f..2ef43095d509cac518631a3a31e0f7f796f3d482 100644 (file)
--- a/src/rrd_open.c
+++ b/src/rrd_open.c
rrd_set_error("live_head_t malloc");
goto out_close;
}
-#ifdef HAVE_MMAP
- memmove(&rrd->live_head->last_up, data + offset, sizeof(long));
- offset += sizeof(long);
-#else
- offset += read(rrd_file->fd, &rrd->live_head->last_up, sizeof(long));
-#endif
+
+#if defined USE_MADVISE
+ /* the live_head will be needed soonish, so hint accordingly */
+ madvise(data + PAGE_START(offset),
+ sizeof(time_t), MADV_WILLNEED);
+#endif
+ __rrd_read(rrd->legacy_last_up,time_t,1);
+ rrd->live_head->last_up = *rrd->legacy_last_up;
rrd->live_head->last_up_usec = 0;
} else {
#if defined USE_MADVISE
rrd->ds_def = NULL;
rrd->rra_def = NULL;
rrd->live_head = NULL;
+ rrd->legacy_last_up = NULL;
rrd->rra_ptr = NULL;
rrd->pdp_prep = NULL;
rrd->cdp_prep = NULL;
/* free RRD header data. */
#ifdef HAVE_MMAP
-inline void rrd_free(
- rrd_t UNUSED(*rrd))
+void rrd_free(
+ rrd_t *rrd)
{
+ if (rrd->legacy_last_up){ /* this gets set for version < 3 only */
+ free(rrd->live_head);
+ }
}
#else
void rrd_free(
diff --git a/src/rrd_update.c b/src/rrd_update.c
index d861e9e776f7740b0e0b68629d58fe6bbc3c7a21..becce2c4fbb67c251a77dad8e22d602fadce8ada 100644 (file)
--- a/src/rrd_update.c
+++ b/src/rrd_update.c
rrd->live_head->last_up = *current_time;
rrd->live_head->last_up_usec = *current_time_usec;
+ if ( version < 3 ){
+ *rrd->legacy_last_up = rrd->live_head->last_up;
+ }
free(seasonal_coef);
free(last_seasonal_coef);
return 0;
return -1;
}
} else {
- if (rrd_write(rrd_file, &rrd->live_head->last_up,
+ if (rrd_write(rrd_file, rrd->legacy_last_up,
sizeof(time_t) * 1) != sizeof(time_t) * 1) {
rrd_set_error("rrd_write live_head to rrd");
return -1;