[master] e88f87b Polishing

Poul-Henning Kamp phk at FreeBSD.org
Wed Sep 24 10:56:58 CEST 2014


commit e88f87b46f9851fac89a4900603de2d559f1543a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Sep 24 08:56:50 2014 +0000

    Polishing

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 92a4f71..dd3c62a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -695,7 +695,7 @@ void VCA_FailSess(struct worker *w);
 void VBE_UseHealth(const struct director *vdi);
 void VBE_DiscardHealth(const struct director *vdi);
 
-
+/* cache_dir.c */
 int VDI_GetHdr(struct worker *wrk, struct busyobj *bo);
 struct vbc *VDI_GetFd(const struct director *d, struct worker *wrk,
     struct busyobj *);
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 36c31c0..5888180 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -26,43 +26,21 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * This is the central switch-board for backend connections and it is
- * slightly complicated by a number of optimizations.
+ * Backend and Director APIs
  *
- * The data structures:
+ * A director ("VDI") is an abstract entity which can either satisfy a
+ * backend fetch request or select another director for the job.
  *
- *    A vrt_backend is a definition of a backend in a VCL program.
+ * In theory a director does not have to talk HTTP over TCP, it can satisfy
+ * the backend request using any means it wants, although this is presently
+ * not implemented.
  *
- *    A backend is a TCP destination, possibly multi-homed and it has a
- *    number of associated properties and statistics.
+ * A backend ("VBE") is a director which talks HTTP over TCP.
  *
- *    A vbc is an open TCP connection to a backend.
- *
- *    A bereq is a memory carrier for handling a HTTP transaction with
- *    a backend over a vbc.
- *
- *    A director is a piece of code that selects which backend to use,
- *    by whatever method or metric it chooses.
- *
- * The relationships:
- *
- *    Backends and directors get instantiated when VCL's are loaded,
- *    and this always happen in the CLI thread.
- *
- *    When a VCL tries to instantiate a backend, any existing backend
- *    with the same identity (== definition in VCL) will be used instead
- *    so that vbc's can be reused across VCL changes.
- *
- *    Directors disapper with the VCL that created them.
- *
- *    Backends disappear when their reference count drop to zero.
- *
- *    Backends have their host/port name looked up to addrinfo structures
- *    when they are instantiated, and we just cache that result and cycle
- *    through the entries (for multihomed backends) on failure only.
- *    XXX: add cli command to redo lookup.
- *
- *    bereq is sort of a step-child here, we just manage the pool of them.
+ * As you'll notice the terminology is a bit muddled here, but we try to
+ * keep it clean on the user-facing side, where a "director" is always
+ * a "pick a backend/director" functionality, and a "backend" is whatever
+ * satisfies the actual request in the end.
  *
  */
 
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index b8cc79c..639c4b4 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Handle backend connections and backend request structures.
+ * Abstract backend API
  *
  */
 
@@ -161,5 +161,6 @@ VDI_Healthy(const struct director *d)
 {
 
 	CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
+	AN(d->healthy);
 	return (d->healthy(d, NULL));
 }
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index a4aa167..5e27e76 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -133,7 +133,8 @@ vbf_beresp2obj(struct busyobj *bo)
 		return (-1);
 
 	if (vary != NULL) {
-		b = ObjSetattr(bo->wrk, bo->fetch_objcore, OA_VARY, varyl, VSB_data(vary));
+		b = ObjSetattr(bo->wrk, bo->fetch_objcore, OA_VARY, varyl,
+		    VSB_data(vary));
 		VSB_delete(vary);
 	}
 
@@ -149,7 +150,8 @@ vbf_beresp2obj(struct busyobj *bo)
 	    bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS);
 
 	if (http_GetHdr(bo->beresp, H_Last_Modified, &b))
-		AZ(ObjSetDouble(bo->wrk, bo->fetch_objcore, OA_LASTMODIFIED, VTIM_parse(b)));
+		AZ(ObjSetDouble(bo->wrk, bo->fetch_objcore, OA_LASTMODIFIED,
+		    VTIM_parse(b)));
 	else
 		AZ(ObjSetDouble(bo->wrk, bo->fetch_objcore, OA_LASTMODIFIED,
 		    floor(bo->fetch_objcore->exp.t_origin)));



More information about the varnish-commit mailing list