From 4b09919f70b171bc6e053bc3014ffc0e36bc1ff1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Jacke?= Date: Wed, 25 Aug 2010 12:23:50 +0200 Subject: [PATCH] s4:process_thread: use monotonic time for time deltas --- source4/smbd/process_thread.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 8af785dd40b..c047d23d268 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -233,17 +233,18 @@ static int thread_mutex_destroy(smb_mutex_t *mutex, const char *name) return pthread_mutex_destroy((pthread_mutex_t *)mutex->mutex); } -static void mutex_start_timer(struct timeval *tp1) +static void mutex_start_timer(struct timespec *tp1) { - gettimeofday(tp1,NULL); + clock_gettime_mono(tp1); } -static double mutex_end_timer(struct timeval tp1) +static double mutex_end_timer(struct timespec tp1) { - struct timeval tp2; - gettimeofday(&tp2,NULL); + struct timespec tp2; + + clock_gettime_mono(&tp2); return((tp2.tv_sec - tp1.tv_sec) + - (tp2.tv_usec - tp1.tv_usec)*1.0e-6); + (tp2.tv_nsec - tp1.tv_nsec)*1.0e-9); } /* @@ -254,7 +255,7 @@ static int thread_mutex_lock(smb_mutex_t *mutexP, const char *name) pthread_mutex_t *mutex = (pthread_mutex_t *)mutexP->mutex; int rc; double t; - struct timeval tp1; + struct timespec tp1; /* Test below is ONLY for debugging */ if ((rc = pthread_mutex_trylock(mutex))) { if (rc == EBUSY) { @@ -316,7 +317,7 @@ static int thread_rwlock_lock_read(smb_rwlock_t *rwlockP, const char *name) pthread_rwlock_t *rwlock = (pthread_rwlock_t *)rwlockP->rwlock; int rc; double t; - struct timeval tp1; + struct time tp1; /* Test below is ONLY for debugging */ if ((rc = pthread_rwlock_tryrdlock(rwlock))) { if (rc == EBUSY) { @@ -345,7 +346,7 @@ static int thread_rwlock_lock_write(smb_rwlock_t *rwlockP, const char *name) pthread_rwlock_t *rwlock = (pthread_rwlock_t *)rwlockP->rwlock; int rc; double t; - struct timeval tp1; + struct timespec tp1; /* Test below is ONLY for debugging */ if ((rc = pthread_rwlock_trywrlock(rwlock))) { if (rc == EBUSY) { -- 2.11.4.GIT