summaryrefslogtreecommitdiffstats
path: root/source/lib/time.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-11 21:52:46 +0000
committerJeremy Allison <jra@samba.org>2002-01-11 21:52:46 +0000
commit24ee18c77e1b61004d8ed817118a481f3d43e34c (patch)
tree35e43fb351f87b7a5da29dfb15f3bf8421aabf2a /source/lib/time.c
parent01ff6ce4963e1daff019f2b936cef218e1c93f67 (diff)
downloadsamba-24ee18c77e1b61004d8ed817118a481f3d43e34c.tar.gz
samba-24ee18c77e1b61004d8ed817118a481f3d43e34c.tar.xz
samba-24ee18c77e1b61004d8ed817118a481f3d43e34c.zip
Latest attempt at changeid.
Jeremy.
Diffstat (limited to 'source/lib/time.c')
-rw-r--r--source/lib/time.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/source/lib/time.c b/source/lib/time.c
index f0f62ca8419..975c58c7a59 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -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;
}
/*******************************************************************