mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
abstime.c: add 7 day offset to time_monotonic() functions
The start point of the monotonic clock is undefined, but in practice it is often zero. There is lots of code that does not assume that a timestamp can be that low and then fails in subtle ways. Add a 7 day offset to the clock value to work around that. git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1271 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -10,7 +10,7 @@ time_t time_monotonic_ms(void)
|
||||
perror("time_monotonic_ms clock_gettime");
|
||||
return -1;
|
||||
}
|
||||
ret = (t.tv_sec & 0x01FFFFF) * 1000; /* avoid overflow */
|
||||
ret = ((t.tv_sec + 604800)& 0x01FFFFF) * 1000; /* avoid overflow */
|
||||
ret += t.tv_nsec / 1000000;
|
||||
return ret;
|
||||
}
|
||||
@@ -23,5 +23,7 @@ time_t time_monotonic(void)
|
||||
perror("time_monotonic clock_gettime");
|
||||
return -1;
|
||||
}
|
||||
return t.tv_sec;
|
||||
/* CLOCK_MONOTONIC is often == uptime, so starts at 0. Bad for relative
|
||||
time comparisons if the uptime is low, so add 7 days */
|
||||
return t.tv_sec + 604800;
|
||||
}
|
||||
|
Reference in New Issue
Block a user