[4.1] d771942 Hide backends and directors implementation details

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Sep 4 15:54:55 CEST 2015


commit d771942c0c6f151e267b63bbc548a4d4371b25be
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Sun Aug 23 12:29:29 2015 +0200

    Hide backends and directors implementation details
    
    Don't install cache_backend.h and cache_director.h, they expose more
    than what a VMOD needs to see.
    
    The VRT API jumps directly from struct vrt_backend to struct director,
    which makes struct backend more than simply opaque, it is completely
    invisible. However struct director needs to be visible and has been
    moved to cache.h along with its functions definitions.

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index dd2bae2..eb01348 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -99,6 +99,8 @@ varnishd_SOURCES = \
 
 noinst_HEADERS = \
 	builtin_vcl.h \
+	cache/cache_backend.h \
+	cache/cache_director.h \
 	cache/cache_esi.h \
 	cache/cache_pool.h \
 	common/heritage.h \
@@ -116,8 +118,6 @@ noinst_HEADERS = \
 nobase_pkginclude_HEADERS = \
 	cache/cache.h \
 	cache/cache_filter.h \
-	cache/cache_backend.h \
-	cache/cache_director.h \
 	common/common.h \
 	common/params.h \
 	waiter/waiter.h
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 648dad4..ed72296 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -190,6 +190,47 @@ struct http {
 };
 
 /*--------------------------------------------------------------------
+ * Director public APIs
+ */
+
+typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *,
+    double *changed);
+
+typedef const struct director *vdi_resolve_f(const struct director *,
+    struct worker *, struct busyobj *);
+
+typedef int vdi_gethdrs_f(const struct director *, struct worker *,
+    struct busyobj *);
+typedef int vdi_getbody_f(const struct director *, struct worker *,
+    struct busyobj *);
+typedef const struct suckaddr *vdi_getip_f(const struct director *,
+    struct worker *, struct busyobj *);
+typedef void vdi_finish_f(const struct director *, struct worker *,
+    struct busyobj *);
+
+typedef void vdi_http1pipe_f(const struct director *, struct req *,
+    struct busyobj *);
+
+typedef void vdi_panic_f(const struct director *, struct vsb *);
+
+struct director {
+	unsigned		magic;
+#define DIRECTOR_MAGIC		0x3336351d
+	const char		*name;
+	char			*vcl_name;
+	vdi_http1pipe_f		*http1pipe;
+	vdi_healthy_f		*healthy;
+	vdi_resolve_f		*resolve;
+	vdi_gethdrs_f		*gethdrs;
+	vdi_getbody_f		*getbody;
+	vdi_getip_f		*getip;
+	vdi_finish_f		*finish;
+	vdi_panic_f		*panic;
+	void			*priv;
+	const void		*priv2;
+};
+
+/*--------------------------------------------------------------------
  * VFP filter state
  */
 
diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h
index cf20dc1..3bccf80 100644
--- a/bin/varnishd/cache/cache_director.h
+++ b/bin/varnishd/cache/cache_director.h
@@ -37,49 +37,6 @@
  *
  */
 
-/*--------------------------------------------------------------------
- * A director is a piece of code which selects one of possibly multiple
- * backends to use.
- */
-
-
-typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *,
-    double *changed);
-
-typedef const struct director *vdi_resolve_f(const struct director *,
-    struct worker *, struct busyobj *);
-
-typedef int vdi_gethdrs_f(const struct director *, struct worker *,
-    struct busyobj *);
-typedef int vdi_getbody_f(const struct director *, struct worker *,
-    struct busyobj *);
-typedef const struct suckaddr *vdi_getip_f(const struct director *,
-    struct worker *, struct busyobj *);
-typedef void vdi_finish_f(const struct director *, struct worker *,
-    struct busyobj *);
-
-typedef void vdi_http1pipe_f(const struct director *, struct req *,
-    struct busyobj *);
-
-typedef void vdi_panic_f(const struct director *, struct vsb *);
-
-struct director {
-	unsigned		magic;
-#define DIRECTOR_MAGIC		0x3336351d
-	const char		*name;
-	char			*vcl_name;
-	vdi_http1pipe_f		*http1pipe;
-	vdi_healthy_f		*healthy;
-	vdi_resolve_f		*resolve;
-	vdi_gethdrs_f		*gethdrs;
-	vdi_getbody_f		*getbody;
-	vdi_getip_f		*getip;
-	vdi_finish_f		*finish;
-	vdi_panic_f		*panic;
-	void			*priv;
-	const void		*priv2;
-};
-
 /* cache_director.c */
 
 int VDI_GetHdr(struct worker *, struct busyobj *);
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index 411df34..1738bcf 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 
 #include "cache/cache.h"
-#include "cache/cache_director.h"
 
 #include "vrt.h"
 #include "vbm.h"



More information about the varnish-commit mailing list