r5452 breaks compilation for systems which don't have pthread_timedjoin_np().
This patch brings back the old code for such systems with one modification:
pthread_join() is only called if pthread_cancel() does not return an error.
Also, it changes exec_file_thread to exit with pthread_exit rather than
return().
With this patch and http://www.varnish-cache.org/trac/ticket/663, make check
succeeds without error on Opensolaris snv_134, except for m00001.vtc, which did
already fail before for another reason I haven't yet understood (vmod doesn't
get unloaded after vcl destroy).
I haven't tested it on other platforms.
Index: configure.ac
===================================================================
--- configure.ac (revision 5458)
+++ configure.ac (working copy)
@@ -162,6 +162,7 @@
LIBS="${PTHREAD_LIBS}"
AC_CHECK_FUNCS([pthread_set_name_np])
AC_CHECK_FUNCS([pthread_mutex_isowned_np])
+AC_CHECK_FUNCS([pthread_timedjoin_np])
LIBS="${save_LIBS}"
# sendfile is tricky: there are multiple versions, and most of them
Index: bin/varnishtest/vtc.c
===================================================================
--- bin/varnishtest/vtc.c (revision 5458)
+++ bin/varnishtest/vtc.c (working copy)
@@ -64,6 +64,10 @@
pthread_t vtc_thread;
char vtc_tmpdir[PATH_MAX];
static struct vtclog *vltop;
+#ifndef HAVE_PTHREAD_TIMEDJOIN_NP
+static pthread_mutex_t vtc_mtx;
+static pthread_cond_t vtc_cond;
+#endif
/**********************************************************************
* Macro facility
@@ -513,7 +517,12 @@
vtc_log(vltop, 1, "RESETTING after %s", pe->fn);
reset_cmds(cmds);
vtc_error = old_err;
- return (NULL);
+#ifndef HAVE_PTHREAD_TIMEDJOIN_NP
+ AZ(pthread_mutex_lock(&vtc_mtx));
+ AZ(pthread_cond_signal(&vtc_cond));
+ AZ(pthread_mutex_unlock(&vtc_mtx));
+#endif
+ pthread_exit(NULL);
}
static double
@@ -541,17 +550,42 @@
ts.tv_sec = (long)floor(t);
ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9);
+#ifdef HAVE_PTHREAD_TIMEDJOIN_NP
AZ(pthread_create(&pt, NULL, exec_file_thread, &pe));
i = pthread_timedjoin_np(pt, &v, &ts);
memset(&vtc_thread, 0, sizeof vtc_thread);
if (i != 0) {
- if (i != ETIMEDOUT)
+ if (i == ETIMEDOUT)
+ vtc_log(vltop, 1, "Test timed out");
+ else
+ vtc_log(vltop, 1, "Weird timejoin return: %d %s",
+ i, strerror(i));
+ vtc_error = 1;
+ }
+#else
+ AZ(pthread_mutex_lock(&vtc_mtx));
+ AZ(pthread_create(&pt, NULL, exec_file_thread, &pe));
+ i = pthread_cond_timedwait(&vtc_cond, &vtc_mtx, &ts);
+ memset(&vtc_thread, 0, sizeof vtc_thread);
+
+ if (i == 0) {
+ AZ(pthread_mutex_unlock(&vtc_mtx));
+ AZ(pthread_join(pt, &v));
+ } else {
+ if (i == ETIMEDOUT)
+ vtc_log(vltop, 1, "Test timed out");
+ else
vtc_log(vltop, 1, "Weird condwait return: %d %s",
i, strerror(i));
- vtc_log(vltop, 1, "Test timed out");
+
+ AZ(pthread_mutex_unlock(&vtc_mtx));
+ if (! pthread_cancel(pt))
+ AZ(pthread_join(pt, &v));
+
vtc_error = 1;
}
+#endif
if (vtc_error)
vtc_log(vltop, 1, "TEST %s FAILED", fn);
@@ -633,6 +667,11 @@
AZ(mkdir(vtc_tmpdir, 0700));
macro_def(vltop, NULL, "tmpdir", vtc_tmpdir);
+#ifndef HAVE_PTHREAD_TIMEDJOIN_NP
+ AZ(pthread_mutex_init(&vtc_mtx, NULL));
+ AZ(pthread_cond_init(&vtc_cond, NULL));
+#endif
+
cwd = getcwd(NULL, PATH_MAX);
bprintf(topbuild, "%s/%s", cwd, TOP_BUILDDIR);
macro_def(vltop, NULL, "topbuild", topbuild);
_______________________________________________
varnish-dev mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-dev