[master] 01f0e71 Directors are allowed to fail to pick a backend.
Poul-Henning Kamp
phk at FreeBSD.org
Mon May 19 09:19:43 CEST 2014
commit 01f0e719f90bba1219426fa25abcd6cf3b68eebd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 19 07:19:17 2014 +0000
Directors are allowed to fail to pick a backend.
Fixes #1501
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0f49a3b..7ad709d 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -181,7 +181,6 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC);
assert(bo->state == BOS_INVALID);
- AN(bo->director);
AZ(bo->vbc);
AZ(bo->should_close);
AZ(bo->storage_hint);
@@ -255,7 +254,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
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);
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 4ddacb1..11c712e 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -300,6 +300,10 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req)
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
htc = &bo->htc;
+ if (bo->director == NULL) {
+ VSLb(bo->vsl, SLT_FetchError, "No backend");
+ return (-1);
+ }
AN(bo->director);
hp = bo->bereq;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index b68031c..65c72db 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -270,9 +270,8 @@ VRT_r_beresp_backend_name(const struct vrt_ctx *ctx)
CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC);
return (ctx->bo->vbc->backend->vcl_name);
}
- if (ctx->bo->director != NULL) {
+ if (ctx->bo->director != NULL)
return (ctx->bo->director->vcl_name);
- }
return (NULL);
}
@@ -350,7 +349,6 @@ VRT_l_bereq_backend(const struct vrt_ctx *ctx, struct director *be)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
- AN(ctx->bo->director);
ctx->bo->director = be;
}
@@ -360,7 +358,6 @@ VRT_r_bereq_backend(const struct vrt_ctx *ctx)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
- AN(ctx->bo->director);
return (ctx->bo->director);
}
diff --git a/bin/varnishtest/tests/r01501.vtc b/bin/varnishtest/tests/r01501.vtc
new file mode 100644
index 0000000..c7ce3b8
--- /dev/null
+++ b/bin/varnishtest/tests/r01501.vtc
@@ -0,0 +1,21 @@
+varnishtest "director fails to pick backend"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+
+ import ${vmod_debug};
+
+ sub vcl_recv {
+ set req.backend_hint = debug.no_backend();
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 503
+} -run
More information about the varnish-commit
mailing list