summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b8f9d7)
raw | patch | inline | side by side (parent: 1b8f9d7)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 11 Nov 2010 16:06:55 +0000 (16:06 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 11 Nov 2010 16:06:55 +0000 (16:06 +0000) |
architectures near the timestamp 2^31 (oh yes - y2k038 is showing its ugly
face) when using the graph command(s). Once the endtime of a graph is
above the mentioned timestamp, mktime always returns -1 (and correctly
so), causing some loops to loop forever. The patch fixes this, causing
some strange output, but there is no other sane way to handle this (expect
by switching to a 64 bit platform). -- Peter Stamfest
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2146 a5681a0c-68f1-0310-ab6d-d61299d08faa
face) when using the graph command(s). Once the endtime of a graph is
above the mentioned timestamp, mktime always returns -1 (and correctly
so), causing some loops to loop forever. The patch fixes this, causing
some strange output, but there is no other sane way to handle this (expect
by switching to a 64 bit platform). -- Peter Stamfest
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2146 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/src/rrd_graph.c | patch | blob | history |
index d902a933fc9606417f9afeaac40115cb5fc1436f..b101b329388332d74209d3809431d938a7f57d67 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
localtime_r(¤t, &tm);
+ int limit = 2;
+ switch (baseint) {
+ case TMT_SECOND: limit = 7200; break;
+ case TMT_MINUTE: limit = 120; break;
+ case TMT_HOUR: limit = 2; break;
+ default: limit = 2; break;
+ }
do {
switch (baseint) {
case TMT_SECOND:
tm. tm_year += basestep;
}
madetime = mktime(&tm);
- } while (madetime == -1); /* this is necessary to skip impssible times
+ } while (madetime == -1 && limit-- >= 0); /* this is necessary to skip impossible times
like the daylight saving time skips */
return madetime;
mgridtm,
im->xlab_user.
mgridst);
- ti < im->end;
+ ti < im->end && ti != -1;
ti =
find_next_time(ti, im->xlab_user.gridtm, im->xlab_user.gridst)
) {
/* are we inside the graph ? */
if (ti < im->start || ti > im->end)
continue;
- while (timajor < ti) {
+ while (timajor < ti && timajor != -1) {
timajor = find_next_time(timajor,
im->
xlab_user.
mgridtm, im->xlab_user.mgridst);
}
+ if (timajor == -1) break; /* fail in case of problems with time increments */
if (ti == timajor)
continue; /* skip as falls on major grid line */
X0 = xtr(im, ti);
im->
xlab_user.
mgridst);
- ti < im->end;
+ ti < im->end && ti != -1;
ti = find_next_time(ti, im->xlab_user.mgridtm, im->xlab_user.mgridst)
) {
/* are we inside the graph ? */
labtm,
im->xlab_user.
labst);
- ti <=
+ (ti <=
im->end -
- im->xlab_user.precis / 2;
+ im->xlab_user.precis / 2) && ti != -1;
ti = find_next_time(ti, im->xlab_user.labtm, im->xlab_user.labst)
) {
tilab = ti + im->xlab_user.precis / 2; /* correct time for the label */