From 37038d197a95a27f9dd7dd2cadcd272e129041cb Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 27 Feb 1991 14:27:56 +0000 Subject: [PATCH] Added a hack so that krb5_us_timeofday() will always return a monotonically increasing time, bumping the microsecond time if necessary. This is needed on OS's like ultrix which only have a 10 us granularity in their clock, and don't guarantee in the kernel that two calls to gettimeofday will return different values. This guarantees it in user space, which isn't quite good enough (two different processes communicating over the loopback interface could get confused), but it's better than nothing. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1811 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ustime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/krb5/os/ustime.c b/src/lib/krb5/os/ustime.c index 974e942cc..65146492f 100644 --- a/src/lib/krb5/os/ustime.c +++ b/src/lib/krb5/os/ustime.c @@ -24,6 +24,8 @@ static char rcsid_mstime_c[] = extern int errno; +static struct timeval last_tv = {0, 0}; + krb5_error_code krb5_us_timeofday(seconds, microseconds) register krb5_int32 *seconds, *microseconds; @@ -34,6 +36,11 @@ register krb5_int32 *seconds, *microseconds; /* failed, return errno */ return (krb5_error_code) errno; } + if ((tv.tv_sec == last_tv.tv_sec) && (tv.tv_usec == last_tv.tv_usec)) + tv.tv_usec = ++last_tv.tv_usec; + else + last_tv = tv; + *seconds = tv.tv_sec; *microseconds = tv.tv_usec; return 0; -- 2.26.2