[master] 59db320 Sort vrt.h and vcl.h out.

Poul-Henning Kamp phk at FreeBSD.org
Sat Sep 23 10:16:10 UTC 2017


commit 59db32098f8d0c0f658d7a05994837abddca7b6f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Sep 23 09:56:28 2017 +0000

    Sort vrt.h and vcl.h out.
    
    vrt.h is required before vcl.h, which only contains the table
    generated parts of the VRT api.

diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 64154f4..04d65ba 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -38,9 +38,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "vcl.h"
 #include "vcli_serve.h"
 #include "vrt.h"
+#include "vcl.h"
 #include "vtim.h"
 
 #include "cache_director.h"
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 2eb23bf..01d1eac 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -34,6 +34,7 @@
 #include "cache_filter.h"
 #include "hash/hash_slinger.h"
 #include "storage/storage.h"
+#include "vrt.h"
 #include "vcl.h"
 #include "vtim.h"
 
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 0b56b80..9e1fbe5 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -45,6 +45,7 @@
 
 #include "hash/hash_slinger.h"
 #include "storage/storage.h"
+#include "vrt.h"
 #include "vcl.h"
 #include "vsha256.h"
 #include "vtim.h"
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index bf8831d..ac7c4d8 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -37,8 +37,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "vcl.h"
 #include "vrt.h"
+#include "vcl.h"
 
 #include "cache_director.h"
 #include "cache_backend.h"
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index cf57413..4f4c64b 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -36,8 +36,8 @@
 #include "cache_director.h"
 #include "hash/hash_slinger.h"
 #include "vav.h"
-#include "vcl.h"
 #include "vrt.h"
+#include "vcl.h"
 #include "vrt_obj.h"
 #include "vsa.h"
 #include "vtcp.h"
diff --git a/include/vrt.h b/include/vrt.h
index 8bba11d..db34e79 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -85,7 +85,6 @@
 /***********************************************************************/
 
 struct VCL_conf;
-struct vrt_acl;
 struct busyobj;
 struct director;
 struct http;
@@ -95,6 +94,7 @@ struct suckaddr;
 struct vcl;
 struct vmod;
 struct vmod_priv;
+struct vrt_acl;
 struct vsb;
 struct vsl_log;
 struct ws;
@@ -166,7 +166,9 @@ struct vrt_ctx {
 
 #define VRT_CTX		const struct vrt_ctx *ctx
 
-/***********************************************************************/
+/***********************************************************************
+ * This is the interface structure to a compiled VMOD
+ */
 
 struct vmod_data {
 	/* The version/id fields must be first, they protect the rest */
@@ -182,16 +184,39 @@ struct vmod_data {
 	const char			*abi;
 };
 
-/***********************************************************************/
+/***********************************************************************
+ * Enum for which HTTP header-sets we can access
+ */
+
+enum gethdr_e {
+	HDR_REQ,
+	HDR_REQ_TOP,
+	HDR_RESP,
+	HDR_OBJ,
+	HDR_BEREQ,
+	HDR_BERESP
+};
 
-enum gethdr_e { HDR_REQ, HDR_REQ_TOP, HDR_RESP, HDR_OBJ, HDR_BEREQ,
-		HDR_BERESP };
+/***********************************************************************
+ * Enum for events sent to compiled VCL and from there to Vmods
+ */
+
+enum vcl_event_e {
+	VCL_EVENT_LOAD,
+	VCL_EVENT_WARM,
+	VCL_EVENT_COLD,
+	VCL_EVENT_DISCARD,
+};
+
+/***********************************************************************/
 
 struct gethdr_s {
 	enum gethdr_e	where;
 	const char	*what;
 };
 
+/***********************************************************************/
+
 extern const void * const vrt_magic_string_end;
 extern const void * const vrt_magic_string_unset;
 
@@ -354,10 +379,6 @@ struct vmod_priv {
 	vmod_priv_free_f	*free;
 };
 
-#ifdef VCL_RET_MAX
-typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e);
-#endif
-
 struct vclref;
 struct vclref * VRT_ref_vcl(VRT_CTX, const char *);
 void VRT_rel_vcl(VRT_CTX, struct vclref **);
@@ -380,3 +401,9 @@ const char *VRT_BOOL_string(VCL_BOOL);
 const char *VRT_BACKEND_string(VCL_BACKEND);
 const char *VRT_STEVEDORE_string(VCL_STEVEDORE);
 const char *VRT_CollectString(VRT_CTX, const char *p, ...);
+
+typedef int vcl_event_f(VRT_CTX, enum vcl_event_e);
+typedef int vcl_init_f(VRT_CTX);
+typedef void vcl_fini_f(VRT_CTX);
+typedef void vcl_func_f(VRT_CTX);
+typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e);
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 64e2167..e65f215 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -1108,25 +1108,14 @@ fo = open(join(buildroot, "include/vcl.h"), "w")
 file_header(fo)
 
 fo.write("""
-struct vrt_ctx;
-#define VRT_CTX const struct vrt_ctx *ctx
-struct req;
-struct busyobj;
-struct ws;
-struct cli;
-struct worker;
-
-enum vcl_event_e {
-	VCL_EVENT_LOAD,
-	VCL_EVENT_WARM,
-	VCL_EVENT_COLD,
-	VCL_EVENT_DISCARD,
-};
-
-typedef int vcl_event_f(VRT_CTX, enum vcl_event_e);
-typedef int vcl_init_f(VRT_CTX);
-typedef void vcl_fini_f(VRT_CTX);
-typedef void vcl_func_f(VRT_CTX);
+#ifdef VCL_H_INCLUDED
+#  error "vcl.h included multiple times"
+#endif
+#define VCL_H_INCLUDED
+
+#ifndef VRT_H_INCLUDED
+#  error "include vrt.h before vcl.h"
+#endif
 """)
 
 
diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c
index 3fcc333..9dd361e 100644
--- a/lib/libvcc/vcc_acl.c
+++ b/lib/libvcc/vcc_acl.c
@@ -39,8 +39,6 @@
 
 #include "vcc_compile.h"
 
-#include "vrt.h"
-
 struct acl_e {
 	VTAILQ_ENTRY(acl_e)	list;
 	unsigned char		data[VRT_ACL_MAXADDR + 1];
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 5a5ffbb..600bcb5 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -32,9 +32,10 @@
 #include <stdint.h>
 
 #include "miniobj.h"
+#include "vdef.h"
 #include "vas.h"
+#include "vrt.h"
 #include "vcl.h"
-#include "vdef.h"
 #include "vqueue.h"
 #include "vsb.h"
 
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 543ed1e..12d21fd 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -37,7 +37,6 @@
 #include "libvcc.h"
 #include "vfil.h"
 #include "vmod_abi.h"
-#include "vrt.h"
 
 static int
 vcc_path_dlopen(void *priv, const char *fn)
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 6636f61..6e40650 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -497,9 +497,7 @@ class s_event(stanza):
 			    self.event_func)
 
 	def hfile(self, fo):
-		fo.write("#ifdef VCL_MET_MAX\n")
 		fo.write("vmod_event_f %s;\n" % self.event_func)
-		fo.write("#endif\n")
 
 	def cstruct(self, fo):
 		fo.write("\tvmod_event_f\t\t\t*_event;\n")
@@ -828,7 +826,7 @@ class vcc(object):
 
 		fo.write('#include "config.h"\n')
 		fo.write('#include <stdio.h>\n')
-		for i in ["vdef", "vcl", "vrt", self.pfx, "vmod_abi"]:
+		for i in ["vdef", "vrt", self.pfx, "vmod_abi"]:
 			fo.write('#include "%s.h"\n' % i)
 
 		fo.write("\n")
diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c
index 7e58db1..40702d1 100644
--- a/lib/libvmod_blob/vmod_blob.c
+++ b/lib/libvmod_blob/vmod_blob.c
@@ -30,7 +30,6 @@
 #include <errno.h>
 #include <pthread.h>
 
-#include "vcl.h"
 #include "vdef.h"
 #include "vrt.h"
 
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 09312cf..8a1fe41 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -34,7 +34,6 @@
 
 #include "cache/cache.h"
 
-#include "vcl.h"
 #include "vrt.h"
 #include "vsa.h"
 #include "vsb.h"
diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c
index eecfb7f..caed6bc 100644
--- a/lib/libvmod_debug/vmod_debug_dyn.c
+++ b/lib/libvmod_debug/vmod_debug_dyn.c
@@ -33,7 +33,6 @@
 
 #include "cache/cache.h"
 
-#include "vcl.h"
 #include "vrt.h"
 
 #include "cache/cache_director.h"
@@ -121,8 +120,7 @@ vmod_dyn__init(VRT_CTX, struct vmod_debug_dyn **dynp,
 	if (*addr == '\0' || *port == '\0') {
 		AN(ctx->handling);
 		AZ(*ctx->handling);
-		VSB_printf(ctx->msg, "Missing dynamic backend address or port");
-		VRT_handling(ctx, VCL_RET_FAIL);
+		VRT_fail(ctx, "Missing dynamic backend address or port");
 		return;
 	}
 


More information about the varnish-commit mailing list