[6.1] 39eae44fc Only do the "feature dns" DNS-lookup if/when necessary.

hermunn hermunn at varnish-software.com
Wed Oct 24 09:29:18 UTC 2018


commit 39eae44fc427689d024c5f9b9dd9d5a150c59c6b
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 6ebff08a5..7483a53b4 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -81,7 +81,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 d6168a2ae..2bc150322 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -95,7 +95,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
@@ -428,39 +427,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
  */
@@ -670,7 +636,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 cc975688c..34f79e045 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: varnishtest varnishtest
@@ -315,6 +317,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
@@ -401,7 +436,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