try CLOCK_BOOTTIME with fallback (#1091992)

This commit is contained in:
Petr Lautrbach 2014-05-14 17:27:32 +02:00
parent f3b39bb6cb
commit 9a031d2641
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,29 @@
--- a/misc.c
+++ b/misc.c
@@ -865,17 +865,24 @@ ms_to_timeval(struct timeval *tv, int ms
time_t
monotime(void)
{
-#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+#if defined(HAVE_CLOCK_GETTIME) && \
+ (defined(CLOCK_MONOTONIC) || defined(CLOCK_BOOTTIME))
struct timespec ts;
static int gettime_failed = 0;
if (!gettime_failed) {
+#if defined(CLOCK_BOOTTIME)
+ if (clock_gettime(CLOCK_BOOTTIME, &ts) == 0)
+ return (ts.tv_sec);
+#endif
+#if defined(CLOCK_MONOTONIC)
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
return (ts.tv_sec);
+#endif
debug3("clock_gettime: %s", strerror(errno));
gettime_failed = 1;
}
-#endif
+#endif /* HAVE_CLOCK_GETTIME && (CLOCK_MONOTONIC || CLOCK_BOOTTIME */
return time(NULL);
}

View File

@ -188,6 +188,8 @@ Patch904: openssh-6.4p1-FIPS-mode-SP800-131A.patch
Patch905: openssh-6.4p1-legacy-ssh-copy-id.patch Patch905: openssh-6.4p1-legacy-ssh-copy-id.patch
# Use tty allocation for a remote scp (#985650) # Use tty allocation for a remote scp (#985650)
Patch906: openssh-6.4p1-fromto-remote.patch Patch906: openssh-6.4p1-fromto-remote.patch
# Try CLOCK_BOOTTIME with fallback (#1091992)
Patch907: openssh-6.4p1-CLOCK_BOOTTIME.patch
License: BSD License: BSD
@ -413,6 +415,7 @@ popd
%patch904 -p1 -b .SP800-131A %patch904 -p1 -b .SP800-131A
%patch905 -p1 -b .legacy-ssh-copy-id %patch905 -p1 -b .legacy-ssh-copy-id
%patch906 -p1 -b .fromto-remote %patch906 -p1 -b .fromto-remote
%patch907 -p1 -b .CLOCK_BOOTTIME
%if 0 %if 0
# Nothing here yet # Nothing here yet