]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
fix init_cdp. The original code implicitly always used the first pdp_prep
authorPeter Stamfest <peter@stamfest.at>
Wed, 13 Aug 2014 18:14:31 +0000 (20:14 +0200)
committerPeter Stamfest <peter@stamfest.at>
Sun, 31 Aug 2014 20:15:31 +0000 (22:15 +0200)
structure of the underlying rrd, which lead to wrong cdp initialization in
experimental code. This change will be needed for future work.

src/rrd_create.c
src/rrd_create.h
src/rrd_modify.c

index 8e4a0ab3641b3c5c48e62c9abbb450c1a5b9da87..712fd3c5c3c4907ed72c5abf30527da0136b21d0 100644 (file)
@@ -768,7 +768,7 @@ rra_def_t * create_hw_contingent_rras(rra_def_t *rra_defs,
      return rra_defs;
 }
 
-void init_cdp(const rrd_t *rrd, const rra_def_t *rra_def, cdp_prep_t *cdp_prep)
+void init_cdp(const rrd_t *rrd, const rra_def_t *rra_def, const pdp_prep_t *pdp_prep, cdp_prep_t *cdp_prep)
 {
 
     switch (cf_conv(rra_def->cf_nam)) {
@@ -795,7 +795,7 @@ void init_cdp(const rrd_t *rrd, const rra_def_t *rra_def, cdp_prep_t *cdp_prep)
             /* startup missing pdp count */
             cdp_prep->scratch[CDP_unkn_pdp_cnt].u_cnt =
                 ((rrd->live_head->last_up -
-                  rrd->pdp_prep->scratch[PDP_unkn_sec_cnt].u_cnt)
+                  pdp_prep->scratch[PDP_unkn_sec_cnt].u_cnt)
                  % (rrd->stat_head->pdp_step
                     * rra_def->pdp_cnt)) / rrd->stat_head->pdp_step;
             break;
@@ -862,7 +862,7 @@ int rrd_create_fn(
 
 
     for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
-       init_cdp(rrd, &(rrd->rra_def[i]), rrd->cdp_prep);
+       init_cdp(rrd, &(rrd->rra_def[i]), rrd->pdp_prep, rrd->cdp_prep);
 
         for (ii = 0; ii < rrd->stat_head->ds_cnt; ii++) {
             rrd_write(rrd_file_dn, rrd->cdp_prep, sizeof(cdp_prep_t));
index c450b04a166fcf9431595a81abaf450785bbe63e..834ab540238a70742633a909212007da2304dd68 100644 (file)
@@ -36,8 +36,11 @@ rra_def_t *handle_dependent_rras(rra_def_t *rra_def_array,
                                 long unsigned int *rra_cnt, 
                                 unsigned long hash);
 
+/** Initialize a cdp_prep structure. The rra_def, pdp_prep and cdp_prep should
+ correspond to each other. Global values are taken from rrd. */
 void init_cdp(const rrd_t *rrd, 
-             const rra_def_t *rra_def, 
+             const rra_def_t *rra_def,
+             const pdp_prep_t *pdp_prep,
              cdp_prep_t *cdp_prep);
 
 int write_rrd(const char *outfilename, rrd_t *out);
index ecfe076d2c83bd39992b053228e924e720747da1..7df7e01d60bcd948de03eb0008576be5cc252d50 100644 (file)
@@ -371,6 +371,7 @@ static int handle_rra_defs(const rrd_t *in, rrd_t *out,
 
                init_cdp(out, 
                         out->rra_def + out->stat_head->rra_cnt,
+                         out->pdp_prep + ii,
                         cdp_prep);
                ii++;
                break;
@@ -1130,7 +1131,7 @@ static void prepare_CDPs(const rrd_t *in, rrd_t *out,
        cdp_prep_t *cdp_prep = out->cdp_prep + start_cdp_index_out + i;
        memcpy(cdp_prep, &empty_cdp_prep, sizeof(cdp_prep_t));
 
-       init_cdp(out, rra_def, cdp_prep);
+       init_cdp(out, rra_def, out->pdp_prep + i, cdp_prep);
 
        if (chosen_candidate && mapped_i != -1) {
            int ds_cnt = chosen_candidate->rrd->stat_head->ds_cnt;