[master] 2d6df8e65 Only do the "feature dns" DNS-lookup if/when necessary.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 1 09:59:11 UTC 2018
commit 2d6df8e651d42da8457e408c02a1552f35226271
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 1 09:54:57 2018 +0000
Only do the "feature dns" DNS-lookup if/when necessary.
Spotted by: Willy Tarreau <w at 1wt.eu>
diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h
index 182f258e9..c091afe40 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -82,7 +82,6 @@ extern char *vmod_path;
extern struct vsb *params_vsb;
extern int leave_temp;
extern int vtc_witness;
-extern int feature_dns;
extern int ign_unknown_macro;
void init_server(void);
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 4e5cf6b2b..01ae08ba7 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -97,7 +97,6 @@ char *vmod_path = NULL;
struct vsb *params_vsb = NULL;
int leave_temp;
int vtc_witness = 0;
-int feature_dns;
/**********************************************************************
* Parse a -D option argument into a name/val pair, and insert
@@ -430,39 +429,6 @@ i_mode(void)
AZ(putenv(strdup("MALLOC_CONF=abort:true,junk:true")));
}
-/**********************************************************************
- * Most test-cases use only numeric IP#'s but a few requires non-demented
- * DNS services. This is a basic sanity check for those.
- */
-
-static int v_matchproto_(vss_resolved_f)
-dns_cb(void *priv, const struct suckaddr *sa)
-{
- char abuf[VTCP_ADDRBUFSIZE];
- char pbuf[VTCP_PORTBUFSIZE];
- int *ret = priv;
-
- VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf);
- if (strcmp(abuf, "192.0.2.255")) {
- fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf);
- *ret = -1;
- } else if (*ret == 0)
- *ret = 1;
- return (0);
-}
-
-static int
-dns_works(void)
-{
- int ret = 0, error;
- const char *msg;
-
- error = VSS_resolver("dns-canary.freebsd.dk", NULL, dns_cb, &ret, &msg);
- if (error || msg != NULL || ret != 1)
- return (0);
- return (1);
-}
-
/**********************************************************************
* Figure out what IP related magic
*/
@@ -682,7 +648,6 @@ main(int argc, char * const *argv)
AZ(VSB_finish(params_vsb));
- feature_dns = dns_works();
ip_magic();
if (iflg)
diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c
index 2fcf5e0e2..b55d4be13 100644
--- a/bin/varnishtest/vtc_misc.c
+++ b/bin/varnishtest/vtc_misc.c
@@ -47,6 +47,8 @@
#include "vnum.h"
#include "vre.h"
+#include "vtcp.h"
+#include "vss.h"
#include "vtim.h"
/* SECTION: vtest vtest
@@ -338,6 +340,39 @@ cmd_delay(CMD_ARGS)
VTIM_sleep(f);
}
+/**********************************************************************
+ * Most test-cases use only numeric IP#'s but a few requires non-demented
+ * DNS services. This is a basic sanity check for those.
+ */
+
+static int v_matchproto_(vss_resolved_f)
+dns_cb(void *priv, const struct suckaddr *sa)
+{
+ char abuf[VTCP_ADDRBUFSIZE];
+ char pbuf[VTCP_PORTBUFSIZE];
+ int *ret = priv;
+
+ VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf);
+ if (strcmp(abuf, "192.0.2.255")) {
+ fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf);
+ *ret = -1;
+ } else if (*ret == 0)
+ *ret = 1;
+ return (0);
+}
+
+static int
+dns_works(void)
+{
+ int ret = 0, error;
+ const char *msg;
+
+ error = VSS_resolver("dns-canary.freebsd.dk", NULL, dns_cb, &ret, &msg);
+ if (error || msg != NULL || ret != 1)
+ return (0);
+ return (1);
+}
+
/* SECTION: feature feature
*
* Test that the required feature(s) for a test are available, and skip
@@ -424,7 +459,7 @@ cmd_feature(CMD_ARGS)
}
FEATURE("pcre_jit", VRE_has_jit);
FEATURE("64bit", sizeof(void*) == 8);
- FEATURE("dns", feature_dns);
+ FEATURE("dns", dns_works());
FEATURE("topbuild", iflg);
FEATURE("root", !geteuid());
FEATURE("user_varnish", getpwnam("varnish") != NULL);
More information about the varnish-commit
mailing list