r4532 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Thu Feb 4 10:09:19 CET 2010


Author: phk
Date: 2010-02-04 10:09:18 +0100 (Thu, 04 Feb 2010)
New Revision: 4532

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
Log:
Use TIM_real() or the benefit of OS/X.

Fixes	#640



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2010-02-03 08:54:09 UTC (rev 4531)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2010-02-04 09:09:18 UTC (rev 4532)
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <math.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -491,7 +492,7 @@
 static double
 exec_file(const char *fn, unsigned dur)
 {
-	double t0;
+	double t0, t;
 	struct priv_exec pe;
 	pthread_t pt;
 	struct timespec ts;
@@ -509,8 +510,9 @@
 		    fn, strerror(errno));
 	pe.fn = fn;
 
-	AZ(clock_gettime(CLOCK_REALTIME, &ts));
-	ts.tv_sec += dur;
+	t = TIM_real() + dur;
+	ts.tv_sec = floor(t);
+	ts.tv_nsec = (t - ts.tv_sec) * 1e9;
 
 	AZ(pthread_mutex_lock(&vtc_mtx));
 	AZ(pthread_create(&pt, NULL, exec_file_thread, &pe));



More information about the varnish-commit mailing list