[master] 2f2ef5909 clarify when we do (not) have ctx->msg

Nils Goroll nils.goroll at uplex.de
Tue Jan 21 16:40:08 UTC 2020


commit 2f2ef5909a90bf7b74dd1f0a29c2228db0cd898d
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Jan 21 15:49:15 2020 +0100

    clarify when we do (not) have ctx->msg
    
    This tests that we are at least consistent, though not necessarily
    correct
    
    See #2902

diff --git a/include/vrt.h b/include/vrt.h
index 168a4251e..979d5b3d9 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -286,7 +286,13 @@ struct vrt_ctx {
 	unsigned			*handling;
 	unsigned			vclver;
 
-	struct vsb			*msg;	// Only in ...init()
+	/*
+	 * msg is for error messages and exists only for
+	 * VCL_EVENT_LOAD
+	 * VCL_EVENT_WARM
+	 * VCL_EVENT_COLD
+	 */
+	struct vsb			*msg;
 	struct vsl_log			*vsl;
 	VCL_VCL				vcl;
 	struct ws			*ws;
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 2c601fe1c..a17760e69 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -495,6 +495,8 @@ event_cold(VRT_CTX, const struct vmod_priv *priv)
 	pthread_t thread;
 	struct priv_vcl *priv_vcl;
 
+	AN(ctx->msg);
+
 	CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
 
 	VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl));
@@ -530,6 +532,8 @@ event_discard(VRT_CTX, void *priv)
 
 	(void)priv;
 
+	AZ(ctx->msg);
+
 	VRT_RemoveVFP(ctx, &xyzzy_rot13);
 	VRT_RemoveVDP(ctx, &xyzzy_vdp_rot13);
 
@@ -557,7 +561,7 @@ xyzzy_event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
 	case VCL_EVENT_WARM:	return (event_warm(ctx, priv));
 	case VCL_EVENT_COLD:	return (event_cold(ctx, priv));
 	case VCL_EVENT_DISCARD:	return (event_discard(ctx, priv));
-	default: return (0);
+	default: WRONG("we should test all possible events");
 	}
 }
 


More information about the varnish-commit mailing list