r3102 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Tue Aug 19 09:19:51 CEST 2008


Author: phk
Date: 2008-08-19 09:19:50 +0200 (Tue, 19 Aug 2008)
New Revision: 3102

Modified:
   trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
   trunk/varnish-cache/include/vrt.h
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Use the default (or specified) Host: header for the backend in the
probe requests.



Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2008-08-18 14:40:51 UTC (rev 3101)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2008-08-19 07:19:50 UTC (rev 3102)
@@ -61,6 +61,7 @@
 	struct backend			*backend;
 	struct vrt_backend_probe 	probe;
 	int				stop;
+	char				*req;
 	int				req_len;
 
 	unsigned			good;
@@ -157,7 +158,7 @@
 		return (0);
 	}
 
-	i = write(s, vt->probe.request, vt->req_len);
+	i = write(s, vt->req, vt->req_len);
 	if (i != vt->req_len) {
 		if (i < 0)
 			vt->err_xmit |= 1;
@@ -243,7 +244,7 @@
 		vt->probe.threshold = 3;
 
 	printf("Probe(\"%s\", %g, %g)\n",
-	    vt->probe.request,
+	    vt->req,
 	    vt->probe.timeout,
 	    vt->probe.interval);
 
@@ -366,6 +367,7 @@
 VBP_Start(struct backend *b, struct vrt_backend_probe const *p)
 {
 	struct vbp_target *vt;
+	struct vsb *vsb;
 
 	ASSERT_CLI();
 
@@ -377,6 +379,27 @@
 	}
 	vt->backend = b;
 	vt->probe = *p;
+
+	if(p->request != NULL) {
+		vt->req = strdup(p->request);
+		XXXAN(vt->req);
+	} else {
+		vsb = vsb_newauto();
+		XXXAN(vsb);
+		vsb_printf(vsb, "GET %s HTTP/1.1\r\n",
+		    p->url != NULL ? p->url : "/");
+		vsb_printf(vsb, "Connection: close\r\n");
+		if (b->hosthdr != NULL)
+			vsb_printf(vsb, "Host: %s\r\n", b->hosthdr);
+		vsb_printf(vsb, "\r\n", b->hosthdr);
+		vsb_finish(vsb);
+		AZ(vsb_overflowed(vsb));
+		vt->req = strdup(vsb_data(vsb));
+		XXXAN(vt->req);
+		vsb_delete(vsb);
+	}
+	vt->req_len = strlen(vt->req);
+
 	b->probe = vt;
 
 	VTAILQ_INSERT_TAIL(&vbp_list, vt, list);

Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h	2008-08-18 14:40:51 UTC (rev 3101)
+++ trunk/varnish-cache/include/vrt.h	2008-08-19 07:19:50 UTC (rev 3102)
@@ -48,6 +48,7 @@
 extern void *vrt_magic_string_end;
 
 struct vrt_backend_probe {
+	char		*url;
 	char		*request;
 	double		timeout;
 	double		interval;

Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-08-18 14:40:51 UTC (rev 3101)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-08-19 07:19:50 UTC (rev 3102)
@@ -364,12 +364,9 @@
 			vcc_ProbeRedef(tl, &t_did, t_field);
 			ERRCHK(tl);
 			ExpectErr(tl, CSTR);
-			Fb(tl, 0, "\t\t.request =\n");
-			Fb(tl, 0, "\t\t\t\"GET \" ");
+			Fb(tl, 0, "\t\t.url = ");
 			EncToken(tl->fb, tl->t);
-			Fb(tl, 0, " \" /HTTP/1.1\\r\\n\"\n");
-			Fb(tl, 0, "\t\t\t\"Connection: close\\r\\n\"\n");
-			Fb(tl, 0, "\t\t\t\"\\r\\n\",\n");
+			Fb(tl, 0, ",\n");
 			vcc_NextToken(tl);
 		} else if (vcc_IdIs(t_field, "request")) {
 			vcc_ProbeRedef(tl, &t_did, t_field);
@@ -703,7 +700,7 @@
 	const char	*name;
 	parsedirector_f	*func;
 } dirlist[] = {
-	{ "random", 	vcc_ParseRandomDirector },
+	{ "random", 		vcc_ParseRandomDirector },
 	{ "round-robin", 	vcc_ParseRoundRobinDirector },
 	{ NULL,		NULL }
 };

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-08-18 14:40:51 UTC (rev 3101)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-08-19 07:19:50 UTC (rev 3102)
@@ -328,6 +328,7 @@
 	vsb_cat(sb, "extern void *vrt_magic_string_end;\n");
 	vsb_cat(sb, "\n");
 	vsb_cat(sb, "struct vrt_backend_probe {\n");
+	vsb_cat(sb, "	char		*url;\n");
 	vsb_cat(sb, "	char		*request;\n");
 	vsb_cat(sb, "	double		timeout;\n");
 	vsb_cat(sb, "	double		interval;\n");




More information about the varnish-commit mailing list