- /* write other rows of the bulk update, if any */
- for (; rra_step_cnt[rra_idx] > 1; rra_step_cnt[rra_idx]--) {
- if (++rrd->rra_ptr[rra_idx].cur_row ==
- rrd->rra_def[rra_idx].row_cnt) {
-#ifdef DEBUG
- fprintf(stderr,
- "Wraparound for RRA %s, %lu updates left\n",
- rrd->rra_def[rra_idx].cf_nam,
- rra_step_cnt[rra_idx] - 1);
-#endif
- /* wrap */
- rrd->rra_ptr[rra_idx].cur_row = 0;
- /* seek back to beginning of current rra */
- if (rrd_seek(rrd_file, rra_start, SEEK_SET) != 0) {
- rrd_set_error("seek error in rrd");
- return -1;
- }
-#ifdef DEBUG
- fprintf(stderr, " -- Wraparound Postseek %ld\n",
- rrd_file->pos);
-#endif
- *rra_current = rra_start;
- }
- if (!skip_update[rra_idx]) {
- if (*pcdp_summary != NULL) {
- rra_time = (current_time - current_time
- % (rrd->rra_def[rra_idx].pdp_cnt *
- rrd->stat_head->pdp_step))
- -
- ((rra_step_cnt[rra_idx] -
- 2) * rrd->rra_def[rra_idx].pdp_cnt *
- rrd->stat_head->pdp_step);
- }
- if (write_RRA_row(rrd_file, rrd, rra_idx, rra_current,
- CDP_secondary_val, pcdp_summary,
- rra_time) == -1)
- return -1;
- }
+ if (skip_update[rra_idx])
+ continue;
+
+ if (*pcdp_summary != NULL) {
+ unsigned long step_time = rra_def->pdp_cnt * rrd->stat_head->pdp_step;
+
+ rra_time = (current_time - current_time % step_time)
+ - ((rra_step_cnt[rra_idx] - step_subtract) * step_time);