r5452 - trunk/varnish-cache/bin/varnishtest

phk at varnish-cache.org phk at varnish-cache.org
Thu Oct 21 21:43:16 CEST 2010


Author: phk
Date: 2010-10-21 21:43:16 +0200 (Thu, 21 Oct 2010)
New Revision: 5452

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc.h
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
   trunk/varnish-cache/bin/varnishtest/vtc_log.c
   trunk/varnish-cache/bin/varnishtest/vtc_sema.c
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
   trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Use the eminently portable but non-portable pthread_timedjoin_np() to
wait for the testcase.



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -37,7 +37,6 @@
 #include <fcntl.h>
 #include <math.h>
 #include <limits.h>
-#include <pthread.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -65,8 +64,6 @@
 pthread_t		vtc_thread;
 char			vtc_tmpdir[PATH_MAX];
 static struct vtclog	*vltop;
-static pthread_mutex_t	vtc_mtx;
-static pthread_cond_t	vtc_cond;
 
 /**********************************************************************
  * Macro facility
@@ -516,9 +513,6 @@
 	vtc_log(vltop, 1, "RESETTING after %s", pe->fn);
 	reset_cmds(cmds);
 	vtc_error = old_err;
-	AZ(pthread_mutex_lock(&vtc_mtx));
-	AZ(pthread_cond_signal(&vtc_cond));
-	AZ(pthread_mutex_unlock(&vtc_mtx));
 	return (NULL);
 }
 
@@ -532,6 +526,7 @@
 	void *v;
 	int i;
 
+	vtc_logreset();
 	t0 = TIM_mono();
 	vtc_stop = 0;
 	vtc_desc = NULL;
@@ -546,37 +541,22 @@
 	ts.tv_sec = (long)floor(t);
 	ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9);
 
-	AZ(pthread_mutex_lock(&vtc_mtx));
 	AZ(pthread_create(&pt, NULL, exec_file_thread, &pe));
-	i = pthread_cond_timedwait(&vtc_cond, &vtc_mtx, &ts);
+	i = pthread_timedjoin_np(pt, &v, &ts);
 	memset(&vtc_thread, 0, sizeof vtc_thread);
 
-	if (i == 0) {
-		AZ(pthread_mutex_unlock(&vtc_mtx));
-		AZ(pthread_join(pt, &v));
-	} else {
-		AZ(pthread_mutex_unlock(&vtc_mtx));
+	if (i != 0) {
 		if (i != ETIMEDOUT)
 			vtc_log(vltop, 1, "Weird condwait return: %d %s",
 			    i, strerror(i));
-		/*
-		 * We are all going to die anyway, so don't waste time
-		 * trying to clean things up, it seems to trigger a
-		 * problem in the tinderbox
-		 *   AZ(pthread_mutex_unlock(&vtc_mtx));
-		 *   AZ(pthread_cancel(pt));
-		 *   AZ(pthread_join(pt, &v));
-		 */
 		vtc_log(vltop, 1, "Test timed out");
 		vtc_error = 1;
 	}
 
 	if (vtc_error)
 		vtc_log(vltop, 1, "TEST %s FAILED", fn);
-	else {
+	else 
 		vtc_log(vltop, 1, "TEST %s completed", fn);
-		vtc_logreset();
-	}
 
 	t0 = TIM_mono() - t0;
 
@@ -604,10 +584,6 @@
  * Main
  */
 
-/**********************************************************************
- * Main
- */
-
 int
 main(int argc, char * const *argv)
 {
@@ -661,9 +637,6 @@
 	bprintf(topbuild, "%s/%s", cwd, TOP_BUILDDIR);
 	macro_def(vltop, NULL, "topbuild", topbuild);
 
-	AZ(pthread_mutex_init(&vtc_mtx, NULL));
-	AZ(pthread_cond_init(&vtc_cond, NULL));
-
 	macro_def(vltop, NULL, "bad_ip", "10.255.255.255");
 	tmax = 0;
 	nmax = NULL;

Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h	2010-10-21 19:43:16 UTC (rev 5452)
@@ -29,6 +29,9 @@
  */
 
 #include <pthread.h>
+#ifdef HAVE_PTHREAD_NP_H
+#include <pthread_np.h>
+#endif
 
 struct vsb;
 struct vtclog;

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -36,7 +36,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <pthread.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -35,7 +35,6 @@
 #include <poll.h>
 #include <stdio.h>
 #include <poll.h>
-#include <pthread.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -37,7 +37,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <pthread.h>
 #include <stdarg.h>
 
 #include "libvarnish.h"

Modified: trunk/varnish-cache/bin/varnishtest/vtc_sema.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -36,7 +36,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <pthread.h>
 
 #include "vtc.h"
 

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <pthread.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-10-21 19:40:21 UTC (rev 5451)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-10-21 19:43:16 UTC (rev 5452)
@@ -41,7 +41,6 @@
 #include <string.h>
 #include <signal.h>
 #include <poll.h>
-#include <pthread.h>
 #include <inttypes.h>
 
 #include <sys/types.h>




More information about the varnish-commit mailing list