[PATCH 1/6] server: Use monotonic clock for relative timeouts.
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> --- Relative timeouts are expected to wait given amount of time even if system clock is changed. It's also behaving incorrectly on daylight saving related time change. server/fd.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 9 deletions(-)
Piotr Caban <piotr(a)codeweavers.com> writes:
+static inline timeout_t monotonic_counter(void) +{ +#ifdef __APPLE__ + static mach_timebase_info_data_t timebase; + + if (!timebase.denom) mach_timebase_info( &timebase ); +#ifdef HAVE_MACH_CONTINUOUS_TIME + if (&mach_continuous_time != NULL) + return mach_continuous_time() * timebase.numer / timebase.denom / 1000000; +#endif + return mach_absolute_time() * timebase.numer / timebase.denom / 1000000; +#elif defined(HAVE_CLOCK_GETTIME) + struct timespec ts; +#ifdef CLOCK_MONOTONIC_RAW + if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts )) + return (timeout_t)ts.tv_sec * TICKS_PER_SEC + ts.tv_nsec / 100; +#endif + if (!clock_gettime( CLOCK_MONOTONIC, &ts )) + return (timeout_t)ts.tv_sec * TICKS_PER_SEC + ts.tv_nsec / 100; +#endif + return current_time - server_start_time; +}
We have almost the same function in request.c, I don't think we want two of these. Also you didn't change the scaling for the Mac case. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Piotr Caban