[master] e1f2e3d simplify vmod_shard_backend() LAZY handling

Nils Goroll nils.goroll at uplex.de
Fri Mar 9 15:42:09 UTC 2018


commit e1f2e3d6377ec61922d90f197b2723ea28228c3f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Mar 9 14:13:21 2018 +0100

    simplify vmod_shard_backend() LAZY handling

diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c
index 1ecd9f3..b672249 100644
--- a/lib/libvmod_directors/vmod_shard.c
+++ b/lib/libvmod_directors/vmod_shard.c
@@ -606,27 +606,20 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
 
 	switch (resolve) {
 	case LAZY:
-		if ((ctx->method & VCL_MET_TASK_B) == 0) {
-			if ((args & ~arg_resolve) != 0) {
-				VRT_fail(ctx,
-					 "shard .backend resolve=LAZY "
-					 "with other parameters can "
-					 "only be used in backend "
-					 "context");
-				return (NULL);
-			}
+		if ((args & ~arg_resolve) == 0) {
 			AN(vshard->dir);
 			return (vshard->dir);
 		}
 
-		assert(ctx->method & VCL_MET_TASK_B);
-
-		if ((args & ~arg_resolve) == 0) {
-			/* no other parameters - shortcut */
-			AN(vshard->dir);
-			return (vshard->dir);
+		if ((ctx->method & VCL_MET_TASK_B) == 0) {
+			VRT_fail(ctx, "shard .backend resolve=LAZY with other "
+				 "parameters can only be used in backend "
+				 "context");
+			return (NULL);
 		}
 
+		assert(ctx->method & VCL_MET_TASK_B);
+
 		pp = shard_param_task(ctx, vshard, vshard->param);
 		if (pp == NULL)
 			return (NULL);


More information about the varnish-commit mailing list