r4392 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Dec 14 14:03:09 CET 2009


Author: phk
Date: 2009-12-14 14:03:08 +0100 (Mon, 14 Dec 2009)
New Revision: 4392

Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Execute vcl_hash{} right after vcl_recv{}, so that vcl_pipe{} and vcl_pass{}
can trust the result to exist.



Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-12-14 12:10:15 UTC (rev 4391)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-12-14 13:03:08 UTC (rev 4392)
@@ -775,12 +775,6 @@
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 
-	if (sp->obj == NULL) {
-		HSH_BeforeVclHash(sp);
-		VCL_hash_method(sp);
-		assert(sp->handling == VCL_RET_HASH);
-		HSH_AfterVclHash(sp);
-	}
 
 	oc = HSH_Lookup(sp, &oh);
 
@@ -1015,6 +1009,7 @@
 static int
 cnt_recv(struct sess *sp)
 {
+	unsigned recv_handling;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
@@ -1030,6 +1025,8 @@
 	sp->disable_esi = 0;
 
 	VCL_recv_method(sp);
+	recv_handling = sp->handling;
+
 	if (sp->restarts >= params->max_restarts) {
 		if (sp->err_code == 0)
 			sp->err_code = 503;
@@ -1037,6 +1034,11 @@
 		return (0);
 	}
 
+	HSH_BeforeVclHash(sp);
+	VCL_hash_method(sp);
+	assert(sp->handling == VCL_RET_HASH);
+	HSH_AfterVclHash(sp);
+
 	if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) {
 		sp->wantbody = 0;
 		http_ForceGet(sp->http);
@@ -1044,7 +1046,7 @@
 		sp->wantbody = 1;
 
 	sp->sendbody = 0;
-	switch(sp->handling) {
+	switch(recv_handling) {
 	case VCL_RET_LOOKUP:
 		/* XXX: discard req body, if any */
 		sp->step = STP_LOOKUP;



More information about the varnish-commit mailing list