From 991b73e6e765a963bb156582be64ef651b897706 Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 3 Dec 2008 11:08:48 +0000 Subject: [PATCH] When fetching data from 'past' an rra, rrd_fetch was seeking past the rrd file. This did cause seek errors in some setups. Fixed. Thanks to Daniel Pocock for finding the problem. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1689 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_fetch.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/program/src/rrd_fetch.c b/program/src/rrd_fetch.c index 370dc1fb..b6aab91c 100644 --- a/program/src/rrd_fetch.c +++ b/program/src/rrd_fetch.c @@ -359,21 +359,25 @@ int rrd_fetch_fn( /* fill the gap at the start if needs be */ - if (start_offset <= 0) - rra_pointer = rrd.rra_ptr[chosen_rra].cur_row + 1; - else - rra_pointer = rrd.rra_ptr[chosen_rra].cur_row + 1 + start_offset; - - if (rrd_seek(rrd_file, (rra_base + (rra_pointer * (*ds_cnt) - * sizeof(rrd_value_t))), + if (*start <= rra_end_time && *end >= rra_start_time - *step){ + + if (start_offset <= 0) + rra_pointer = rrd.rra_ptr[chosen_rra].cur_row + 1; + else + rra_pointer = rrd.rra_ptr[chosen_rra].cur_row + 1 + start_offset; + + if (rrd_seek(rrd_file, (rra_base + (rra_pointer * (*ds_cnt) + * sizeof(rrd_value_t))), SEEK_SET) != 0) { - rrd_set_error("seek error in RRA"); - goto err_free_data; - } + rrd_set_error("seek error in RRA"); + goto err_free_data; + } #ifdef DEBUG - fprintf(stderr, "First Seek: rra_base %lu rra_pointer %lu\n", + fprintf(stderr, "First Seek: rra_base %lu rra_pointer %lu\n", rra_base, rra_pointer); #endif + } + /* step trough the array */ for (i = start_offset; -- 2.30.2