Skip to content

Commit

Permalink
never exit from library function ... #653
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Nov 10, 2015
1 parent 2b36d95 commit a9c9778
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/rrd_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ void apply_gridfit(

/* reduce data reimplementation by Alex */

void reduce_data(
int reduce_data(
enum cf_en cf, /* which consolidation function ? */
unsigned long cur_step, /* step the data currently is in */
time_t *start, /* start, end and step as requested ... */
Expand Down Expand Up @@ -841,10 +841,8 @@ void reduce_data(
/* if this gets triggered, something is REALLY WRONG ... we die immediately */

if (row_cnt % reduce_factor) {
printf("SANITY CHECK: %lu rows cannot be reduced by %i \n",
row_cnt, reduce_factor);
printf("BUG in reduce_data()\n");
exit(1);
rrd_set_error("SANITY CHECK: %lu rows cannot be reduced by %i \n", row_cnt, reduce_factor);
return 0;
}

/* Now combine reduce_factor intervals at a time
Expand Down Expand Up @@ -929,6 +927,7 @@ void reduce_data(
printf("\n");
}
#endif
return 1;
}


Expand Down Expand Up @@ -1034,12 +1033,14 @@ int data_fetch(
im->gdes[i].step = max(im->gdes[i].step,im->step);
if (ft_step < im->gdes[i].step) {

reduce_data(im->gdes[i].cf_reduce_set ? im->gdes[i].cf_reduce : im->gdes[i].cf,
if (!reduce_data(im->gdes[i].cf_reduce_set ? im->gdes[i].cf_reduce : im->gdes[i].cf,
ft_step,
&im->gdes[i].start,
&im->gdes[i].end,
&im->gdes[i].step,
&im->gdes[i].ds_cnt, &im->gdes[i].data);
&im->gdes[i].ds_cnt, &im->gdes[i].data)){
return -1;
}
} else {
im->gdes[i].step = ft_step;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rrd_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void expand_range(
image_desc_t *);
void apply_gridfit(
image_desc_t *);
void reduce_data(
int reduce_data(
enum cf_en,
unsigned long,
time_t *,
Expand Down

0 comments on commit a9c9778

Please sign in to comment.