summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2013-07-03 18:57:57 +0200
committerSimo Sorce <idra@samba.org>2013-07-05 16:47:34 +0200
commitcf87f8587415df2119995e82ccf51bb64e44115b (patch)
tree74b9c1afbbd62367cae38da013943450c52734cc /lib/util
parente3c2dd13d4519d89fc78fd36a9ee4552f0f241ac (diff)
downloadsamba-cf87f8587415df2119995e82ccf51bb64e44115b.tar.gz
samba-cf87f8587415df2119995e82ccf51bb64e44115b.tar.bz2
samba-cf87f8587415df2119995e82ccf51bb64e44115b.zip
time: prefer CLOCK_BOOTTIME for clock_gettime_mono()
this clock moves on while the machine was suspended. This is what we prefer actually. Signed-off-by: Björn Jacke <bj@sernet.de> Reviewed-by: Simo Sorce <idra@samba.org> Autobuild-User(master): Simo Sorce <idra@samba.org> Autobuild-Date(master): Fri Jul 5 16:47:34 CEST 2013 on sn-devel-104
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/time.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/util/time.c b/lib/util/time.c
index bc87120859..05251dd3b5 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -62,9 +62,19 @@ a wrapper to preferably get the monotonic time
**/
_PUBLIC_ void clock_gettime_mono(struct timespec *tp)
{
- if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) != 0) {
- clock_gettime(CLOCK_REALTIME,tp);
+/* prefer a suspend aware monotonic CLOCK_BOOTTIME: */
+#ifdef CLOCK_BOOTTIME
+ if (clock_gettime(CLOCK_BOOTTIME,tp) == 0) {
+ return;
}
+#endif
+/* then try the monotonic clock: */
+#if CUSTOM_CLOCK_MONOTONIC != CLOCK_REALTIME
+ if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) == 0) {
+ return;
+ }
+#endif
+ clock_gettime(CLOCK_REALTIME,tp);
}
/**