[master] 629c3f173 Refactor VRT_priv_task()

Nils Goroll nils.goroll at uplex.de
Tue Jan 5 11:37:06 UTC 2021


commit 629c3f173f47375be287cd1fb144776ad673961b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Jan 5 12:26:32 2021 +0100

    Refactor VRT_priv_task()
    
    Pull out determining the privs head
    
    Re-use will come with a PR

diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index fa53089f0..5cd8e06ae 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -139,8 +139,8 @@ vrt_priv_dynamic(struct ws *ws, struct vrt_privs *privs, uintptr_t vmod_id)
 	return (vp->priv);
 }
 
-struct vmod_priv *
-VRT_priv_task(VRT_CTX, const void *vmod_id)
+static struct vrt_privs *
+vrt_priv_task_context(VRT_CTX)
 {
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
@@ -156,27 +156,26 @@ VRT_priv_task(VRT_CTX, const void *vmod_id)
 
 	if (ctx->req) {
 		CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
-		return (vrt_priv_dynamic(
-		    ctx->ws,
-		    ctx->req->privs,
-		    (uintptr_t)vmod_id
-		));
+		return (ctx->req->privs);
 	}
 	if (ctx->bo) {
 		CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
-		return (vrt_priv_dynamic(
-		    ctx->ws,
-		    ctx->bo->privs,
-		    (uintptr_t)vmod_id
-		));
+		return (ctx->bo->privs);
 	}
 	ASSERT_CLI();
+	return (cli_task_privs);
+}
+
+struct vmod_priv *
+VRT_priv_task(VRT_CTX, const void *vmod_id)
+{
+
+	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 
 	return (vrt_priv_dynamic(
 	    ctx->ws,
-	    cli_task_privs,
-	    (uintptr_t)vmod_id
-	));
+	    vrt_priv_task_context(ctx),
+	    (uintptr_t)vmod_id));
 }
 
 struct vmod_priv *


More information about the varnish-commit mailing list