[master] 7f97686 Rename req.backend to req.backend_hint and restrict it to vcl_recv{}
Poul-Henning Kamp
phk at FreeBSD.org
Wed Feb 5 11:46:41 CET 2014
commit 7f9768602064589d122f72aea95e05c894c7e975
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 5 10:44:34 2014 +0000
Rename req.backend to req.backend_hint and restrict it to vcl_recv{}
Rename beresp.storage to beresp.storage_hint for consistency.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 6e522bb..93ec51f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -664,7 +664,7 @@ struct req {
uint16_t err_code;
const char *err_reason;
- struct director *director;
+ struct director *director_hint;
struct VCL_conf *vcl;
char *ws_req; /* WS above request data */
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 2466404..65a24bf 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -144,7 +144,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
bo->do_stream = 1;
- bo->director = req->director;
+ bo->director = req->director_hint;
bo->vcl = req->vcl;
VCL_Ref(bo->vcl);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index eb69164..b7eba44 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -357,7 +357,6 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
wrk = req->wrk;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC);
- AN(req->director);
AN(hash);
hsh_prealloc(wrk);
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 3389f6d..5d0f286 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -183,7 +183,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
CHECK_OBJ_ORNULL(req->vcl, VCL_CONF_MAGIC);
AZ(req->obj);
- req->director = NULL;
+ req->director_hint = NULL;
req->restarts = 0;
AZ(req->esi_level);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index ec7713a..b2f3ef0 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -208,7 +208,7 @@ cnt_error(struct worker *wrk, struct req *req)
bo->stats = NULL;
if (req->obj == NULL) {
req->doclose = SC_OVERLOAD;
- req->director = NULL;
+ req->director_hint = NULL;
AZ(HSH_DerefObjCore(&wrk->stats, &bo->fetch_objcore));
bo->fetch_objcore = NULL;
http_Teardown(bo->beresp);
@@ -634,7 +634,7 @@ cnt_restart(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- req->director = NULL;
+ req->director_hint = NULL;
if (++req->restarts >= cache_param->max_restarts) {
VSLb(req->vsl, SLT_VCL_Error, "Too many restarts");
req->err_code = 503;
@@ -698,9 +698,9 @@ cnt_recv(struct worker *wrk, struct req *req)
}
/* By default we use the first backend */
- AZ(req->director);
- req->director = req->vcl->director[0];
- AN(req->director);
+ AZ(req->director_hint);
+ req->director_hint = req->vcl->director[0];
+ AN(req->director_hint);
req->d_ttl = -1;
req->disable_esi = 0;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index dad35f3..5d875ed 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -279,7 +279,7 @@ VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx)
}
const char *
-VRT_r_beresp_storage(const struct vrt_ctx *ctx)
+VRT_r_beresp_storage_hint(const struct vrt_ctx *ctx)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
@@ -290,7 +290,7 @@ VRT_r_beresp_storage(const struct vrt_ctx *ctx)
}
void
-VRT_l_beresp_storage(const struct vrt_ctx *ctx, const char *str, ...)
+VRT_l_beresp_storage_hint(const struct vrt_ctx *ctx, const char *str, ...)
{
va_list ap;
const char *b;
@@ -326,8 +326,8 @@ VRT_r_req_##nm(const struct vrt_ctx *ctx) \
return(ctx->req->elem); \
}
-REQ_VAR_L(backend, director, struct director *,)
-REQ_VAR_R(backend, director, struct director *)
+REQ_VAR_L(backend_hint, director_hint, struct director *,)
+REQ_VAR_R(backend_hint, director_hint, struct director *)
REQ_VAR_L(ttl, d_ttl, double, if (!(arg>0.0)) arg = 0;)
REQ_VAR_R(ttl, d_ttl, double)
diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc
index fc2478e..f4763ee 100644
--- a/bin/varnishtest/tests/b00016.vtc
+++ b/bin/varnishtest/tests/b00016.vtc
@@ -1,74 +1,42 @@
varnishtest "Check naming of backends"
-varnish v1 -vcl {
- backend foo {
- .host = "${bad_ip}"; .port = "9080";
- }
+server s1 {
+ rxreq
+ txresp
+} -start
- sub vcl_recv {
- return(error(200,"ok"));
- }
+varnish v1 -vcl+backend {
- sub vcl_error {
- set obj.http.X-Backend-Name = req.backend;
+ sub vcl_backend_response {
+ set beresp.http.X-Backend-Name = bereq.backend;
}
} -start
client c1 {
txreq -url "/"
rxresp
- expect resp.http.X-Backend-Name == "foo"
+ expect resp.http.X-Backend-Name == "s1"
} -run
-varnish v1 -vcl {
+varnish v1 -vcl+backend {
import ${vmod_directors};
- backend b1 {
- .host = "${bad_ip}"; .port = "9080";
- }
sub vcl_init {
new bar = directors.random();
- bar.add_backend(b1, 1);
- }
-
- sub vcl_recv {
- set req.backend = bar.backend();
- return(error(200,"ok"));
- }
-
- sub vcl_error {
- set obj.http.X-Backend-Name = req.backend;
- }
-}
-
-client c1 {
- txreq -url "/"
- rxresp
- expect resp.http.X-Backend-Name == "bar"
-} -run
-
-varnish v1 -vcl {
- import ${vmod_directors};
- backend b1 {
- .host = "${bad_ip}"; .port = "9080";
- }
- sub vcl_init {
- new baz = directors.round_robin();
- baz.add_backend(b1);
+ bar.add_backend(s1, 1);
}
sub vcl_recv {
- set req.backend = baz.backend();
- return (error(200,"ok"));
+ set req.backend_hint = bar.backend();
}
- sub vcl_error {
- set obj.http.X-Backend-Name = req.backend;
+ sub vcl_backend_response {
+ set beresp.http.X-Backend-Name = bereq.backend;
}
}
client c1 {
txreq -url "/"
rxresp
- expect resp.http.X-Backend-Name == "baz"
+ expect resp.http.X-Backend-Name == "s1"
} -run
diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc
index fb415eb..9bd7950 100644
--- a/bin/varnishtest/tests/c00044.vtc
+++ b/bin/varnishtest/tests/c00044.vtc
@@ -24,7 +24,7 @@ varnish v1 \
-vcl+backend {
sub vcl_backend_response {
set beresp.do_stream = false;
- set beresp.storage = "invalid";
+ set beresp.storage_hint = "invalid";
}
} -start
diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc
index 23967fa..c653cf0 100644
--- a/bin/varnishtest/tests/c00045.vtc
+++ b/bin/varnishtest/tests/c00045.vtc
@@ -16,7 +16,7 @@ varnish v1 \
-vcl+backend {
sub vcl_backend_response {
set beresp.do_stream = false;
- set beresp.storage = "s0";
+ set beresp.storage_hint = "s0";
}
} -start
diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc
index a2e1d2b..3abea2f 100644
--- a/bin/varnishtest/tests/c00046.vtc
+++ b/bin/varnishtest/tests/c00046.vtc
@@ -15,7 +15,7 @@ varnish v1 \
-arg "-smalloc,1m" \
-vcl+backend {
sub vcl_backend_response {
- set beresp.storage = "s0";
+ set beresp.storage_hint = "s0";
}
} -start
diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc
index 411c4b4..b839a0c 100644
--- a/bin/varnishtest/tests/p00008.vtc
+++ b/bin/varnishtest/tests/p00008.vtc
@@ -20,9 +20,9 @@ varnish v1 \
-arg "-sper2=persistent,${tmpdir}/_.per2,10m" \
-vcl+backend {
sub vcl_backend_response {
- set beresp.storage = "per1";
+ set beresp.storage_hint = "per1";
if (bereq.url ~ "silo2") {
- set beresp.storage = "per2";
+ set beresp.storage_hint = "per2";
}
}
} -start
diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc
index 5539b20..5624c20 100644
--- a/bin/varnishtest/tests/r01175.vtc
+++ b/bin/varnishtest/tests/r01175.vtc
@@ -7,7 +7,7 @@ server s1 {
varnish v1 -arg "-s test=malloc,1M" -vcl+backend {
sub vcl_backend_response {
- set beresp.storage = "test";
+ set beresp.storage_hint = "test";
set beresp.do_stream = false;
}
} -start
diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc
index 015b2fa..9b843ce 100644
--- a/bin/varnishtest/tests/r01283.vtc
+++ b/bin/varnishtest/tests/r01283.vtc
@@ -16,7 +16,7 @@ varnish v1 \
}
sub vcl_backend_response {
set beresp.do_stream = false;
- set beresp.storage = "Transient";
+ set beresp.storage_hint = "Transient";
}
} -start
diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc
index 68dc456..697f104 100644
--- a/bin/varnishtest/tests/r01284.vtc
+++ b/bin/varnishtest/tests/r01284.vtc
@@ -15,7 +15,7 @@ varnish v1 \
-vcl+backend {
sub vcl_backend_response {
set beresp.do_stream = false;
- set beresp.storage = "Transient";
+ set beresp.storage_hint = "Transient";
}
} -start
diff --git a/bin/varnishtest/tests/v00033.vtc b/bin/varnishtest/tests/v00033.vtc
index d3eecc3..a10fac1 100644
--- a/bin/varnishtest/tests/v00033.vtc
+++ b/bin/varnishtest/tests/v00033.vtc
@@ -15,7 +15,7 @@ varnish v1 -vcl+backend {
storage.nowhere.free_space +
1 B + 1 KB + 1 MB + 1GB + 1TB;
if (bereq.url == "/foo") {
- set beresp.storage = "Transient";
+ set beresp.storage_hint = "Transient";
}
}
sub vcl_deliver {
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index a36c2d4..8d8f14f 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -253,11 +253,13 @@ The client's IP address.
Does the client accept the gzip transfer encoding.
"""
),
- ('req.backend',
+ ('req.backend_hint',
'BACKEND',
- ( 'client',),
- ( 'client',), """
- The backend to use to service the request.
+ ( 'recv',),
+ ( 'recv',), """
+ Set bereq.backend to this if we attemt to fetch.
+ This variable is a convenience so the overall
+ policy can be set up once and for all in vcl_recv{}.
"""
),
('req.hash_ignore_busy',
@@ -455,11 +457,11 @@ The client's IP address.
IP of the backend this response was fetched from.
"""
),
- ('beresp.storage',
+ ('beresp.storage_hint',
'STRING',
( 'backend_response',),
( 'backend_response',), """
- Set to force Varnish to save this object to a
+ Hint to Varnish that you want to save this object to a
particular storage backend.
"""
),
More information about the varnish-commit
mailing list