summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2010-08-25 12:23:50 +0200
committerBjörn Jacke <bj@sernet.de>2010-08-31 10:25:54 +0200
commit4b09919f70b171bc6e053bc3014ffc0e36bc1ff1 (patch)
tree4ab472af3640e0a114ef3b2d3adb49cb32768a89 /source4
parentc091b3344badac6241b85c6cf2f7dacb0f06047c (diff)
downloadsamba-4b09919f70b171bc6e053bc3014ffc0e36bc1ff1.tar.gz
samba-4b09919f70b171bc6e053bc3014ffc0e36bc1ff1.tar.bz2
samba-4b09919f70b171bc6e053bc3014ffc0e36bc1ff1.zip
s4:process_thread: use monotonic time for time deltas
Diffstat (limited to 'source4')
-rw-r--r--source4/smbd/process_thread.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c
index 8af785dd40..c047d23d26 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) {