diff options
author | Tim Potter <tpot@samba.org> | 2001-11-23 00:52:29 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-11-23 00:52:29 +0000 |
commit | 79b34d1b11e685d068b9c0ac9a0ec06eaa263d82 (patch) | |
tree | 7333a5c9d1ce43319880185d936a373b0fd8caa2 /source3/lib | |
parent | 5788899a480c3b4c79a1970dbd1634cc3fed4de6 (diff) | |
download | samba-79b34d1b11e685d068b9c0ac9a0ec06eaa263d82.tar.gz samba-79b34d1b11e685d068b9c0ac9a0ec06eaa263d82.tar.bz2 samba-79b34d1b11e685d068b9c0ac9a0ec06eaa263d82.zip |
Removed TimeInit() call from every client program (except for one place
in smbd/process.c where the timezone is reinitialised. Was replaced with
check for a static is_initialised boolean.
(This used to be commit 8fc772c9e5770cd3a8857670214dcff033ebae32)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/time.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/source3/lib/time.c b/source3/lib/time.c index cf088e8ee4..b302726a95 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -27,7 +27,6 @@ */ -int serverzone=0; int extra_time_offset = 0; #ifndef CHAR_BIT @@ -105,21 +104,36 @@ static int TimeZone(time_t t) } +static BOOL done_serverzone_init; -/******************************************************************* -init the time differences -********************************************************************/ -void TimeInit(void) +/* Return the smb serverzone value */ + +static int get_serverzone(void) { - serverzone = TimeZone(time(NULL)); + static int serverzone; - if ((serverzone % 60) != 0) { - DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n")); - } + if (!done_serverzone_init) { + serverzone = TimeZone(time(NULL)); + + if ((serverzone % 60) != 0) { + DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n")); + } - DEBUG(4,("Serverzone is %d\n",serverzone)); + DEBUG(4,("Serverzone is %d\n",serverzone)); + + done_serverzone_init = True; + } + + return serverzone; } +/* Re-read the smb serverzone value */ + +void TimeInit(void) +{ + done_serverzone_init = False; + get_serverzone(); +} /******************************************************************* return the same value as TimeZone, but it should be more efficient. @@ -284,7 +298,7 @@ time_t nt_time_to_unix(NTTIME *nt) ret = (time_t)(d+0.5); /* this takes us from kludge-GMT to real GMT */ - ret -= serverzone; + ret -= get_serverzone(); ret += LocTimeDiff(ret); return(ret); @@ -331,7 +345,7 @@ void unix_to_nt_time(NTTIME *nt, time_t t) } /* this converts GMT to kludge-GMT */ - t -= LocTimeDiff(t) - serverzone; + t -= LocTimeDiff(t) - get_serverzone(); d = (double)(t); d += TIME_FIXUP_CONSTANT; |