Removed TimeInit() call from every client program (except for one place
authorTim Potter <tpot@samba.org>
Fri, 23 Nov 2001 00:52:29 +0000 (00:52 +0000)
committerTim Potter <tpot@samba.org>
Fri, 23 Nov 2001 00:52:29 +0000 (00:52 +0000)
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)

27 files changed:
source3/client/client.c
source3/client/smbmount.c
source3/client/smbspool.c
source3/lib/time.c
source3/nmbd/nmbd.c
source3/nsswitch/wbinfo.c
source3/nsswitch/winbindd.c
source3/nsswitch/wins.c
source3/rpcclient/rpcclient.c
source3/rpcclient/samsync.c
source3/smbd/server.c
source3/torture/locktest.c
source3/torture/locktest2.c
source3/torture/masktest.c
source3/torture/msgtest.c
source3/torture/rpctorture.c
source3/utils/nmblookup.c
source3/utils/pdbedit.c
source3/utils/smbcacls.c
source3/utils/smbcontrol.c
source3/utils/smbfilter.c
source3/utils/smbgroupedit.c
source3/utils/smbpasswd.c
source3/utils/smbtree.c
source3/utils/status.c
source3/utils/testparm.c
source3/utils/testprns.c

index b4b48da285f38d331b83d4e537b584a1059b6e65..7baab4b2043a32bdee62a3b6f8ad9ea05ec94872 100644 (file)
@@ -2450,8 +2450,6 @@ static int do_message_op(void)
                }
        }
 
-       TimeInit();
-
        in_client = True;   /* Make sure that we tell lp_load we are */
 
        old_debug = DEBUGLEVEL;
index f8fc0558cebfa15b33231898aeb55f2d8c0c20b4..f330dcff8d399333d468e398ada15fb54546fce7 100644 (file)
@@ -827,8 +827,6 @@ static void parse_mount_smb(int argc, char **argv)
        else
                setenv("CLI_FORCE_ASCII", "true", 1);
 
-       TimeInit();
-       
        in_client = True;   /* Make sure that we tell lp_load we are */
 
        if (getenv("USER")) {
index 03d4a34060e6e1fe87ef246b3d36e315975c0158..3d049b588e1ffbe0907d60dcd510a21022a1c897 100644 (file)
@@ -187,8 +187,6 @@ static int          smb_print(struct cli_state *, char *, FILE *);
 
   setup_logging("smbspool", True);
 
-  TimeInit();
-
   in_client = True;   /* Make sure that we tell lp_load we are */
 
   if (!lp_load(dyn_CONFIGFILE, True, False, False))
index cf088e8ee43b57478f1196e359a23d62470ab47b..b302726a959cde5daa4ba07f4024ba267230a1c3 100644 (file)
@@ -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;
index 595a65a0cd27b22576ff76d3cbdb39e73df9fd4f..314eead56501cb31b9f03259a27bdbfe5899f505 100644 (file)
@@ -673,8 +673,6 @@ static void usage(char *pname)
 
   sys_srandom(time(NULL) ^ sys_getpid());
 
-  TimeInit();
-
   slprintf(debugf, sizeof(debugf)-1, "%s/log.nmbd", dyn_LOGFILEBASE);
   setup_logging( argv[0], False );
 
index 8dd2e44caa9edbe306d94d112e3e4aa729ff8fde..11185624d18a4d714a738300b6a42dfbec731b23 100644 (file)
@@ -459,8 +459,6 @@ int main(int argc, char **argv)
                }
        }
 
-       TimeInit();
-
        if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
                DEBUG(0, ("error opening config file\n"));
                exit(1);
index 9c8b022f53175ffa69f4c1cd9004135f244b7836..ad3d4e7ac3153897a7a7be0453614e03721e605e 100644 (file)
@@ -735,8 +735,6 @@ int main(int argc, char **argv)
                        *p = 0;
        }
 
-       TimeInit();
-
        if (!reload_services_file(False)) {
                DEBUG(0, ("error opening config file\n"));
                exit(1);
index b66ef88e04e746a8561deba89fea93fc238dc885..e23cf9ea030efc5665b3890f9003724c2d742094 100644 (file)
@@ -73,7 +73,6 @@ struct in_addr *lookup_backend(const char *name, int *count)
        if (!initialised) {
                initialised = 1;
                DEBUGLEVEL = 0;
-               TimeInit();
                setup_logging("nss_wins",True);
                lp_load(dyn_CONFIGFILE,True,False,False);
                load_interfaces();
index 773548a7db3ce6a987000175e9fa388fb61b6e56..c7d1604a0baecb59849a23eb7be0c38212050ed1 100644 (file)
@@ -716,8 +716,6 @@ static void usage(void)
 
        load_interfaces();
 
-       TimeInit();
-
        get_myname((*global_myname)?NULL:global_myname);
        strupper(global_myname);
        
index 9cd5c481b5f20df3eea8d3af125f053264648133..6d75722f35b6fba9bedcfbc25c87008b55079081 100644 (file)
@@ -309,8 +309,6 @@ static struct cli_state *init_connection(struct cli_state *cli,
 
         load_interfaces();
 
-        TimeInit();
-
         /* Check arguments make sense */
 
         if (do_sam_sync && do_sam_repl) {
index c48cb37615445a588edd018cd676b9010ee2d7b8..b08c8e8bda28c436b44ea570a846318c37f0be5c 100644 (file)
@@ -667,8 +667,6 @@ static void usage(char *pname)
 
        append_log = True;
 
-       TimeInit();
-
        if(!specified_logfile) {
                slprintf(debugf, sizeof(debugf)-1, "%s/log.smbd",
                         dyn_LOGFILEBASE);
index 26c0dcbd29ebbbdc19c14c9d1bbfbe504e871645..ccff2b2624a0c077060a409777ba24e7e7763433 100644 (file)
@@ -568,8 +568,6 @@ static void usage(void)
        argc -= NSERVERS;
        argv += NSERVERS;
 
-       TimeInit();
-
        lp_load(dyn_CONFIGFILE,True,False,False);
        load_interfaces();
 
index 5be9e9c02c43b1dd19aaf36db16c93c198ab2b4b..db5e17921c6555e6564f746ef5a4e71ad08b6675 100644 (file)
@@ -558,8 +558,6 @@ static void usage(void)
        argc -= 4;
        argv += 4;
 
-       TimeInit();
-
        lp_load(dyn_CONFIGFILE,True,False,False);
        load_interfaces();
 
index e39caf46bd5f747b212a282d3d48254d16ec6a0d..d57b26bee4d64b4029a424c39a5a31f4418083f0 100644 (file)
@@ -441,8 +441,6 @@ static void usage(void)
        argc -= 1;
        argv += 1;
 
-       TimeInit();
-
        lp_load(dyn_CONFIGFILE,True,False,False);
        load_interfaces();
 
index 31bc1ee6e8d88a3ffba70ff37106fc8f793af8af..9f3c083b8092bf61c5b568e56cd5522eb604798d 100644 (file)
@@ -42,7 +42,6 @@ void pong_message(int msg_type, pid_t src, void *buf, size_t len)
        int i, n;
        char buf[12];
 
-       TimeInit();
        setup_logging(argv[0],True);
        
        lp_load(dyn_CONFIGFILE,False,False,False);
index 27693f557556adc83a9b8f82736780fcc935b700..e767c715e990884f1c0beb9b35ddeb06ed88b6d9 100644 (file)
@@ -292,8 +292,6 @@ enum client_action
 
        setup_logging(pname, True);
 
-       TimeInit();
-
        myumask = umask(0);
        umask(myumask);
 
index 44f0558bf6c8a0af97ed96a144a388dc7cdd63f8..cad9bf85c354caae8500206142220cb803203fdb 100644 (file)
@@ -199,8 +199,6 @@ int main(int argc,char *argv[])
   DEBUGLEVEL = 1;
   *lookup = 0;
 
-  TimeInit();
-
   setup_logging(argv[0],True);
 
   while ((opt = getopt(argc, argv, "d:B:U:i:s:SMrhART")) != EOF)
index 749e33958b35f356cf6746847854d55189852d2c..782848d626861d488ba939c4bf04184c6dd6f3f5 100644 (file)
@@ -552,8 +552,6 @@ int main (int argc, char **argv)
        char *profile_path = NULL;
        char *smbpasswd = NULL;
 
-       TimeInit();
-       
        setup_logging("tdbedit", True);
 
        if (argc < 2) {
index e1d206e0ee39d6b9d31cfaf9da38664c993ecaa5..ae03e193e1881962a97f1ecfdbc9e919dbaa6565 100644 (file)
@@ -829,8 +829,6 @@ You can string acls together with spaces, commas or newlines\n\
        argc -= 2;
        argv += 2;
 
-       TimeInit();
-
        lp_load(dyn_CONFIGFILE,True,False,False);
        load_interfaces();
 
index 8295280974235c0392d43255d92a41dccc5916f3..ce04d7a215825ad083573fa86b4d33e526576354 100644 (file)
@@ -379,7 +379,6 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
        extern int optind;
        BOOL interactive = False;
 
-       TimeInit();
        setup_logging(argv[0],True);
        
        if (argc < 2) usage(True);
index 1a5aedc485063bc7a7ca5e30fbe24f9b809f0b87..c7df7458d236c2fa7d053d2b1a1ae7876991205a 100644 (file)
@@ -224,8 +224,6 @@ int main(int argc, char *argv[])
        char *desthost;
        pstring configfile;
 
-       TimeInit();
-
        setup_logging(argv[0],True);
   
        pstrcpy(configfile,dyn_CONFIGFILE);
index 3e92834d17f0ee319f3dae0727a83e8d717dd694..8d99e8e600d2f644d4c3200b3dfc6debd046db61 100644 (file)
@@ -217,8 +217,6 @@ int main (int argc, char **argv)
 
        enum SID_NAME_USE sid_type;
 
-       TimeInit();
-       
        setup_logging("groupedit", True);
 
        if (argc < 2) {
index b60f919e79045036d5bf0cc6ece31abe4a10e374..8d50b94a0a1f2180e8f23d930565442926e914e7 100644 (file)
@@ -900,8 +900,6 @@ int main(int argc, char **argv)
        set_auth_parameters(argc, argv);
 #endif /* HAVE_SET_AUTH_PARAMETERS */
 
-       TimeInit();
-       
        setup_logging("smbpasswd", True);
        
        if(!initialize_password_db(True)) {
index 9ce8120bbadcb44e1af2d9d177dd7bf89bc654a3..13df0451f0f6f8c652ddec826439c40ed73df6e0 100644 (file)
@@ -338,8 +338,6 @@ static BOOL print_tree(struct user_auth_info *user_info)
 
        setup_logging(argv[0],True);
 
-       TimeInit();
-
        lp_load(dyn_CONFIGFILE,True,False,False);
        load_interfaces();
 
index 5febdd98d8602f3bdcfd8280d31394e46b70965d..e17a6589efe3378b2fb76d72cb96c8886bbb2bad 100644 (file)
@@ -548,7 +548,6 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
        int profile_only = 0, new_debuglevel = -1;
        TDB_CONTEXT *tdb;
 
-       TimeInit();
        setup_logging(argv[0],True);
        
        DEBUGLEVEL = 0;
index 53adbaae91b214eea3e215585cbcd540deb3bad3..c1b8b10a84afac87e67c030487a6b8f7075bfec6 100644 (file)
@@ -188,8 +188,6 @@ int main(int argc, char *argv[])
 
   *term_code = 0;
 
-  TimeInit();
-
   setup_logging(argv[0],True);
   
   while ((opt = getopt(argc, argv,"shL:t:")) != EOF) {
index cf26e8aa40c5ce12436776de45a307be4a3f92e8..c3aa25ada86cb1a043a29d81315c133810df3d9b 100644 (file)
@@ -38,8 +38,6 @@ int main(int argc, char *argv[])
 {
    char *pszTemp;
 
-   TimeInit();
-
    setup_logging(argv[0],True);
 
    if (argc < 2 || argc > 3)