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 */
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(
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;