[master] f825ef93a Utility function for more thorough VRT_CTX sanity checking

Nils Goroll nils.goroll at uplex.de
Mon Nov 30 18:02:07 UTC 2020


commit f825ef93a9fd47701866c1b6e5a695828465ab01
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 30 18:50:29 2020 +0100

    Utility function for more thorough VRT_CTX sanity checking
    
    this needs to live within the exclusive circle of cache_vcl.h includers, so I
    went for cache_vrt_vcl.c just because of the name.

diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index eda1fe3db..6c419136a 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -313,6 +313,30 @@ VCL_DefaultProbe(const struct vcl *vcl)
 
 /*--------------------------------------------------------------------*/
 
+void
+VRT_CTX_Assert(VRT_CTX)
+{
+	CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC);
+
+	if (ctx->msg != NULL)
+		CHECK_OBJ(ctx->msg, VSB_MAGIC);
+	else
+		AN(ctx->vsl);
+	CHECK_OBJ_NOTNULL(ctx->vcl, VCL_MAGIC);
+	WS_Assert(ctx->ws);
+
+	CHECK_OBJ_ORNULL(ctx->sp, SESS_MAGIC);
+
+	CHECK_OBJ_ORNULL(ctx->req, REQ_MAGIC);
+	CHECK_OBJ_ORNULL(ctx->http_req, HTTP_MAGIC);
+	CHECK_OBJ_ORNULL(ctx->http_req_top, HTTP_MAGIC);
+	CHECK_OBJ_ORNULL(ctx->http_resp, HTTP_MAGIC);
+
+	CHECK_OBJ_ORNULL(ctx->bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_ORNULL(ctx->http_bereq, HTTP_MAGIC);
+	CHECK_OBJ_ORNULL(ctx->http_beresp, HTTP_MAGIC);
+}
+
 struct vclref *
 VRT_VCL_Prevent_Cold(VRT_CTX, const char *desc)
 {
diff --git a/include/vrt.h b/include/vrt.h
index 7508a5b22..6f8b8cb52 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -57,6 +57,7 @@
  *	Added VRT_ValidHdr()
  *	struct vmod_priv_methods added
  *	struct vmod_priv free member replaced with methods
+ *	VRT_CTX_Assert() added
  * 12.0 (2020-09-15)
  *	Added VRT_DirectorResolve()
  *	Added VCL_STRING VRT_BLOB_string(VRT_CTX, VCL_BLOB)
@@ -638,6 +639,8 @@ void VRT_VSC_Hide(const struct vsc_seg *);
 void VRT_VSC_Reveal(const struct vsc_seg *);
 size_t VRT_VSC_Overhead(size_t);
 
+void VRT_CTX_Assert(VRT_CTX);
+
 /*
  * API to restrict the VCL in various ways
  */


More information about the varnish-commit mailing list