summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c0788a)
raw | patch | inline | side by side (parent: 4c0788a)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 3 Dec 2008 11:08:48 +0000 (11:08 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 3 Dec 2008 11:08:48 +0000 (11:08 +0000) |
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/trunk/program@1689 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1689 a5681a0c-68f1-0310-ab6d-d61299d08faa
src/rrd_fetch.c | patch | blob | history |
diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c
index abfe66c89a8483a1b1fb9d482ed5857f889f7d1e..33465b31deed3b0a8b789f34e2bfc66f1f79540a 100644 (file)
--- a/src/rrd_fetch.c
+++ b/src/rrd_fetch.c
#include "rrd_client.h"
#include "rrd_is_thread_safe.h"
-/*#define DEBUG*/
+/* #define DEBUG */
int rrd_fetch(
int argc,
"rra_start %lu, rra_end %lu, start_off %li, end_off %li\n",
rra_start_time, rra_end_time, start_offset, end_offset);
#endif
-
- /* 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)
+ /* only seek if the start time is before the end time */
+ 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",
- rra_base, rra_pointer);
+ fprintf(stderr, "First Seek: rra_base %lu rra_pointer %lu\n",
+ rra_base, rra_pointer);
#endif
+ }
+
/* step trough the array */
for (i = start_offset;