From: phk Date: Thu, 21 Aug 2008 08:48:29 +0000 (+0000) Subject: Make the director opaque outside the backend code. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19ec8fa0520ced50a354cbd32c793ff1acf5fba0;p=varnish Make the director opaque outside the backend code. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3119 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 0560ae68..e7385e9b 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -76,6 +76,7 @@ enum { struct cli; struct vsb; struct sess; +struct director; struct object; struct objhead; struct objexp; @@ -372,22 +373,6 @@ struct sess { const char **hashptr; }; -/* ------------------------------------------------------------------- - * A director is a piece of code which selects one of possibly multiple - * backends to use. - */ - -typedef struct backend *vdi_choose_f(struct sess *sp); -typedef void vdi_fini_f(struct director *d); - -struct director { - unsigned magic; -#define DIRECTOR_MAGIC 0x3336351d - const char *name; - vdi_choose_f *choose; - vdi_fini_f *fini; - void *priv; -}; /* -------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_backend.h b/varnish-cache/bin/varnishd/cache_backend.h index 2abdf353..21641cfa 100644 --- a/varnish-cache/bin/varnishd/cache_backend.h +++ b/varnish-cache/bin/varnishd/cache_backend.h @@ -71,6 +71,23 @@ struct vbp_target; struct vrt_backend_probe; +/* ------------------------------------------------------------------- + * A director is a piece of code which selects one of possibly multiple + * backends to use. + */ + +typedef struct backend *vdi_choose_f(struct sess *sp); +typedef void vdi_fini_f(struct director *d); + +struct director { + unsigned magic; +#define DIRECTOR_MAGIC 0x3336351d + const char *name; + vdi_choose_f *choose; + vdi_fini_f *fini; + void *priv; +}; + /* Backend indstance */ struct backend { unsigned magic; diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 193fdd8a..885dc025 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -388,12 +388,11 @@ cnt_fetch(struct sess *sp) CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC); AN(sp->bereq); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); + AN(sp->director); i = Fetch(sp); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); + AN(sp->director); if (i) { -VSL(SLT_Debug, sp->fd, "Fetch = %d", i); sp->err_code = 503; sp->step = STP_ERROR; VBE_free_bereq(sp->bereq); @@ -854,7 +853,7 @@ cnt_recv(struct sess *sp) /* By default we use the first backend */ AZ(sp->director); sp->director = sp->vcl->director[0]; - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); + AN(sp->director); VCL_recv_method(sp); @@ -996,7 +995,6 @@ CNT_Session(struct sess *sp) CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); - CHECK_OBJ_ORNULL(sp->director, DIRECTOR_MAGIC); switch (sp->step) { #define STEP(l,u) \ diff --git a/varnish-cache/bin/varnishd/cache_dir_random.c b/varnish-cache/bin/varnishd/cache_dir_random.c index f2890c38..4eedee13 100644 --- a/varnish-cache/bin/varnishd/cache_dir_random.c +++ b/varnish-cache/bin/varnishd/cache_dir_random.c @@ -43,6 +43,7 @@ #include "shmlog.h" #include "cache.h" +#include "cache_backend.h" #include "vrt.h" /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_dir_round_robin.c b/varnish-cache/bin/varnishd/cache_dir_round_robin.c index 18fe8b19..70efa4ad 100644 --- a/varnish-cache/bin/varnishd/cache_dir_round_robin.c +++ b/varnish-cache/bin/varnishd/cache_dir_round_robin.c @@ -41,6 +41,7 @@ #include "shmlog.h" #include "cache.h" +#include "cache_backend.h" #include "vrt.h" /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_dir_simple.c b/varnish-cache/bin/varnishd/cache_dir_simple.c index 672d4d55..1fb9ac17 100644 --- a/varnish-cache/bin/varnishd/cache_dir_simple.c +++ b/varnish-cache/bin/varnishd/cache_dir_simple.c @@ -43,6 +43,7 @@ #include "shmlog.h" #include "cache.h" +#include "cache_backend.h" #include "vrt.h" /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 681d894c..19b6771a 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -321,7 +321,7 @@ Fetch(struct sess *sp) CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC); - CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC); + AN(sp->director); assert(sp->obj->busy != 0); w = sp->wrk; bereq = sp->bereq;