[master] df2bced Add the pristine copy of the bereq, which we will need for retrying fetches.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Jun 25 15:09:23 CEST 2013
commit df2bced191f7aa6f4434299dcaac10a3271bfeed
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jun 25 13:08:47 2013 +0000
Add the pristine copy of the bereq, which we will need for retrying
fetches.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index fb67dee..f08feeb 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -523,6 +523,7 @@ struct busyobj {
struct ws ws[1];
struct vbc *vbc;
+ struct http *bereq0;
struct http *bereq;
struct http *beresp;
struct objcore *fetch_objcore;
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 47e61b3..a23c791 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -116,6 +116,11 @@ VBO_GetBusyObj(struct worker *wrk, struct req *req)
nhttp = (uint16_t)cache_param->http_max_hdr;
sz = HTTP_estimate(nhttp);
+ bo->bereq0 = HTTP_create(p, nhttp);
+ p += sz;
+ p = (void*)PRNDUP(p);
+ assert(p < bo->end);
+
bo->bereq = HTTP_create(p, nhttp);
p += sz;
p = (void*)PRNDUP(p);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index a557c23..5df6096 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -60,7 +60,6 @@ vbf_release_req(struct req ***reqpp)
static enum fetch_step
vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo, const struct req *req)
{
- int i;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -71,23 +70,46 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo, const struct req *req)
AZ(bo->should_close);
AZ(bo->storage_hint);
- HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
- http_FilterReq(bo->bereq, req->http,
+ HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, HTTP_Bereq);
+ http_FilterReq(bo->bereq0, req->http,
bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH);
if (!bo->do_pass) {
// XXX: Forcing GET should happen in vcl_miss{} ?
- http_ForceGet(bo->bereq);
+ http_ForceGet(bo->bereq0);
if (cache_param->http_gzip_support) {
/*
* We always ask the backend for gzip, even if the
* client doesn't grok it. We will uncompress for
* the minority of clients which don't.
*/
- http_Unset(bo->bereq, H_Accept_Encoding);
- http_SetHeader(bo->bereq, "Accept-Encoding: gzip");
+ http_Unset(bo->bereq0, H_Accept_Encoding);
+ http_SetHeader(bo->bereq0, "Accept-Encoding: gzip");
}
}
+ return (F_STP_STARTFETCH);
+}
+
+/*--------------------------------------------------------------------
+ * Copy req->bereq and run it by VCL::vcl_backend_fetch{}
+ */
+
+static enum fetch_step
+vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
+{
+ int i;
+
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+
+ AN(bo->director);
+ AZ(bo->vbc);
+ AZ(bo->should_close);
+ AZ(bo->storage_hint);
+
+ HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
+ HTTP_Copy(bo->bereq, bo->bereq0);
+
// Don't let VCL reset do_pass
i = bo->do_pass;
VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws);
diff --git a/bin/varnishtest/tests/r01038.vtc b/bin/varnishtest/tests/r01038.vtc
index ea04142..bb57072 100644
--- a/bin/varnishtest/tests/r01038.vtc
+++ b/bin/varnishtest/tests/r01038.vtc
@@ -45,7 +45,7 @@ server s1 {
txresp -body "foo8"
} -start
-varnish v1 -arg "-p workspace_backend=8k" -vcl+backend {
+varnish v1 -arg "-p workspace_backend=9k" -vcl+backend {
sub vcl_backend_response {
set beresp.do_esi = true;
}
diff --git a/include/tbl/steps.h b/include/tbl/steps.h
index b0589ff..9767191 100644
--- a/include/tbl/steps.h
+++ b/include/tbl/steps.h
@@ -51,6 +51,7 @@ REQ_STEP(error, ERROR, (wrk, req))
#ifdef FETCH_STEP
FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo, *reqp))
+FETCH_STEP(startfetch, STARTFETCH, (wrk, bo))
FETCH_STEP(fetchhdr, FETCHHDR, (wrk, bo, &reqp))
FETCH_STEP(fetch, FETCH, (wrk, bo))
FETCH_STEP(abandon, ABANDON, (wrk, bo, &reqp))
More information about the varnish-commit
mailing list