From 56e72337b01216dc7cba418f040a5cc928e5fc6f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Jun 2011 11:21:15 +0930 Subject: lib/util/time.c: timeval_current_ofs_msec Several places want "milliseconds from current time", and several were simply doing "msec * 1000" which can (and does in one place) result in a usec value over 1 a million. Using a helper to do this is safer and more readable. Signed-off-by: Rusty Russell --- lib/util/time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/util/time.c') diff --git a/lib/util/time.c b/lib/util/time.c index 4843fc96972..de1553aff8a 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -579,6 +579,15 @@ _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) return timeval_add(&tv, secs, usecs); } +/** + return a timeval milliseconds into the future +*/ +_PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs) +{ + struct timeval tv = timeval_current(); + return timeval_add(&tv, msecs / 1000, (msecs % 1000) * 1000); +} + /** compare two timeval structures. Return -1 if tv1 < tv2 -- cgit From 0204ae6229bae3573b3194c3f657c8f385c0b940 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Jun 2011 11:24:51 +0930 Subject: lib/util/time.c: timeval_current_ofs_usec Several places want "microseconds from current time", and several were simply handing "usecs" values which could be over a million. Using a helper to do this is safer and more readable. I didn't replace any obviously correct callers (ie. constants). I also renamed wait_nsec in source3/lib/util_sock.c; it's actually microseconds not nanoseconds (introduced with this code in Volker's 19b783cc Async wrapper for open_socket_out_send/recv). Signed-off-by: Rusty Russell --- lib/util/time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/util/time.c') diff --git a/lib/util/time.c b/lib/util/time.c index de1553aff8a..d8fd4a3dfcc 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -588,6 +588,15 @@ _PUBLIC_ struct timeval timeval_current_ofs_msec(uint32_t msecs) return timeval_add(&tv, msecs / 1000, (msecs % 1000) * 1000); } +/** + return a timeval microseconds into the future +*/ +_PUBLIC_ struct timeval timeval_current_ofs_usec(uint32_t usecs) +{ + struct timeval tv = timeval_current(); + return timeval_add(&tv, usecs / 1000000, usecs % 1000000); +} + /** compare two timeval structures. Return -1 if tv1 < tv2 -- cgit From 530e4cac2e93177923080daa5ec1bac2c65d269b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 11 Jun 2011 09:49:12 +1000 Subject: s3-param Remove 'time offset' from smb.conf This strange parameter is apparently very rarely used, and it seems to me that on modern networks, if clients don't have correct clocks and DST offsets, that many other things (Kerberos) start to fail pretty quickly, and time and DST tables tend to be internet delivered anyway. Autobuild-User: Andrew Bartlett Autobuild-Date: Sat Jun 11 03:54:45 CEST 2011 on sn-devel-104 --- lib/util/time.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/util/time.c') diff --git a/lib/util/time.c b/lib/util/time.c index d8fd4a3dfcc..31aa05cd0f5 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -738,8 +738,6 @@ static int tm_diff(struct tm *a, struct tm *b) } -int extra_time_offset=0; - /** return the UTC offset in seconds west of UTC, or 0 if it cannot be determined */ @@ -753,7 +751,7 @@ _PUBLIC_ int get_time_zone(time_t t) tm = localtime(&t); if (!tm) return 0; - return tm_diff(&tm_utc,tm)+60*extra_time_offset; + return tm_diff(&tm_utc,tm); } struct timespec nt_time_to_unix_timespec(NTTIME *nt) -- cgit