s3: lib: In create_clock_itime(), use timespec_current() -> clock_gettime(CLOCK_REALT...
authorJeremy Allison <jra@samba.org>
Mon, 10 Jan 2022 17:01:09 +0000 (09:01 -0800)
committerJeremy Allison <jra@samba.org>
Mon, 10 Jan 2022 17:49:27 +0000 (17:49 +0000)
CLOCK_MONOTONIC (which we previously used) is reset
when the system is rebooted.

CLOCK_REALTIME is a "wall clock" time. It's still affected by NTP
changes (for Linux we should probably use CLOCK_TAI instead
but that is Linux-specific). For most systems CLOCK_REALTIME
will be good enough.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/system.c

index 0eb3d8564260473e860c1c65b0d2c2cf163d5e6b..ed481da20c67ce8a2f85a4f9ff8fac83170cb4eb 100644 (file)
@@ -323,7 +323,7 @@ void create_clock_itime(struct stat_ex *dst)
        uint8_t rval;
 
        /* Start with the system clock. */
-       clock_gettime_mono(&itime);
+       itime = timespec_current();
 
        /* Convert to NTTIME. */
        tval = unix_timespec_to_nt_time(itime);