r3118 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Aug 21 10:37:37 CEST 2008


Author: phk
Date: 2008-08-21 10:37:37 +0200 (Thu, 21 Aug 2008)
New Revision: 3118

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Move selection of backend and creation of default Host: header until
we actually need to get a filedescriptor to the backend.

This also makes it evident for vcl_pass{}, vcl_pipe{} and vcl_miss{}
if the client sent a Host: header or not.  Previously these functions
saw the default Host: header.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2008-08-21 08:14:40 UTC (rev 3117)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2008-08-21 08:37:37 UTC (rev 3118)
@@ -412,7 +412,7 @@
 
 /* cache_backend.c */
 
-struct vbe_conn *VBE_GetFd(const struct sess *sp);
+struct vbe_conn *VBE_GetFd(struct sess *sp);
 void VBE_ClosedFd(struct worker *w, struct vbe_conn *vc);
 void VBE_RecycleFd(struct worker *w, struct vbe_conn *vc);
 struct bereq * VBE_new_bereq(void);

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2008-08-21 08:14:40 UTC (rev 3117)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2008-08-21 08:37:37 UTC (rev 3118)
@@ -267,13 +267,16 @@
 /*--------------------------------------------------------------------*/
 
 struct vbe_conn *
-VBE_GetFd(const struct sess *sp)
+VBE_GetFd(struct sess *sp)
 {
 	struct backend *bp;
 	struct vbe_conn *vc;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+
+	VBE_SelectBackend(sp);
 	bp = sp->backend;
+	CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
 
 	/* first look for vbe_conn's we can recycle */
 	while (1) {

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2008-08-21 08:14:40 UTC (rev 3117)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2008-08-21 08:37:37 UTC (rev 3118)
@@ -686,7 +686,6 @@
 	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 
-	VBE_SelectBackend(sp);
 	http_FilterHeader(sp, HTTPH_R_FETCH);
 	VCL_miss_method(sp);
 	switch(sp->handling) {
@@ -761,7 +760,6 @@
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 	AZ(sp->obj);
 
-	VBE_SelectBackend(sp);
 	http_FilterHeader(sp, HTTPH_R_PASS);
 
 	VCL_pass_method(sp);
@@ -813,7 +811,6 @@
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 
 	sp->wrk->acct.pipe++;
-	VBE_SelectBackend(sp);
 	http_FilterHeader(sp, HTTPH_R_PIPE);
 
 	VCL_pipe_method(sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-08-21 08:14:40 UTC (rev 3117)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2008-08-21 08:37:37 UTC (rev 3118)
@@ -335,6 +335,15 @@
 	vc = VBE_GetFd(sp);
 	if (vc == NULL)
 		return (__LINE__);
+
+	/*
+	 * Now that we know our backend, we can set a default Host:
+	 * header if one is necessary.
+	 * XXX: This possibly ought to go into the default VCL
+	 */
+	if (!http_GetHdr(hp, H_Host, &b)) 
+		VBE_AddHostHeader(sp);
+
 	TCP_blocking(vc->fd);	/* XXX: we should timeout instead */
 	WRK_Reset(w, &vc->fd);
 	http_Write(w, hp, 0);	/* XXX: stats ? */

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2008-08-21 08:14:40 UTC (rev 3117)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2008-08-21 08:37:37 UTC (rev 3118)
@@ -642,7 +642,6 @@
 {
 	struct bereq *bereq;
 	struct http *hp;
-	char *b;
 
         bereq = VBE_new_bereq();
         AN(bereq);
@@ -656,10 +655,6 @@
 	    "X-Forwarded-For: %s", sp->addr);
 
 	sp->bereq = bereq;
-
-	/* XXX: This possibly ought to go into the default VCL */
-	if (!http_GetHdr(hp, H_Host, &b)) 
-		VBE_AddHostHeader(sp);
 }
 
 /*--------------------------------------------------------------------




More information about the varnish-commit mailing list