Latest attempt at changeid.
authorJeremy Allison <jra@samba.org>
Fri, 11 Jan 2002 21:52:46 +0000 (21:52 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 11 Jan 2002 21:52:46 +0000 (21:52 +0000)
Jeremy.
(This used to be commit 24ee18c77e1b61004d8ed817118a481f3d43e34c)

source3/lib/time.c
source3/printing/nt_printing.c

index f0f62ca84197672c61444b69313d24a6159281a5..975c58c7a596ac54b6069621ea2f2b26e44d0de9 100644 (file)
@@ -129,10 +129,34 @@ static int get_serverzone(void)
 
 /* Re-read the smb serverzone value */
 
+static struct timeval start_time_hires;
+
 void TimeInit(void)
 {
-        done_serverzone_init = False;
-        get_serverzone();
+       done_serverzone_init = False;
+       get_serverzone();
+       /* Save the start time of this process. */
+       GetTimeOfDay(&start_time_hires);
+}
+
+/**********************************************************************
+ Return a timeval struct of the uptime of this process. As TimeInit is
+ done before a daemon fork then this is the start time from the parent
+ daemon start. JRA.
+***********************************************************************/
+
+void get_process_uptime(struct timeval *ret_time)
+{
+       struct timeval time_now_hires;
+
+       GetTimeOfDay(&time_now_hires);
+       ret_time->tv_sec = time_now_hires.tv_sec - start_time_hires.tv_sec;
+       ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
+       if (time_now_hires.tv_usec < start_time_hires.tv_usec) {
+               ret_time->tv_sec -= 1;
+               ret_time->tv_usec = 1000000 + (time_now_hires.tv_usec - start_time_hires.tv_usec);
+       } else
+               ret_time->tv_usec = time_now_hires.tv_usec - start_time_hires.tv_usec;
 }
 
 /*******************************************************************
index d1ab5ce21d1abb2778948b0a8b000701ae153c53..608ba9f21ff43eb61c49849555e4b6138f3d1731 100644 (file)
@@ -2651,10 +2651,11 @@ void get_printer_subst_params(int snum, fstring *printername, fstring *sharename
 
 static uint32 rev_changeid(void)
 {
-       static time_t start_time;
-       if (start_time == 0)
-               start_time = time(NULL);
-       return (((time(NULL) - start_time)+1)*1000);
+       struct timeval tv;
+
+       get_process_uptime(&tv);
+       /* This value is in ms * 100 */
+       return (tv.tv_sec * 100000) + (tv.tv_usec / 10);
 }
 
 /*