summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 41d9659)
raw | patch | inline | side by side (parent: 41d9659)
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/branches/1.4/program@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/branches/1.4/program@2146 a5681a0c-68f1-0310-ab6d-d61299d08faa
src/rrd_graph.c | patch | blob | history |
diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index def9c9ccea38089d7d38bf8032bf9686f217d278..16e8d45f215b8908af884fadbb4f06d9e3be14fb 100644 (file)
--- a/src/rrd_graph.c
+++ b/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 */