[master] b103cc1 Abstract the body setup so that directors can use other means than HTTP/1
Poul-Henning Kamp
phk at FreeBSD.org
Wed Sep 24 11:23:05 CEST 2014
commit b103cc1d47529e0c40166388b096513f33833e47
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Sep 24 09:22:40 2014 +0000
Abstract the body setup so that directors can use other means than HTTP/1
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 4c00753..ba692fb 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -425,6 +425,19 @@ vdi_simple_gethdrs(const struct director *d, struct worker *wrk,
return (i);
}
+static int __match_proto__(vdi_getbody_f)
+vdi_simple_getbody(const struct director *d, struct worker *wrk,
+ struct busyobj *bo)
+{
+
+ CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+
+ V1F_Setup_Fetch(bo->vfc, bo->htc);
+ return (0);
+}
+
/*--------------------------------------------------------------------*/
void
@@ -463,6 +476,7 @@ VRT_init_dir(struct cli *cli, struct director **bp, int idx, const void *priv)
vs->dir.getfd = vdi_simple_getfd;
vs->dir.healthy = vdi_simple_healthy;
vs->dir.gethdrs = vdi_simple_gethdrs;
+ vs->dir.getbody = vdi_simple_getbody;
vs->vrt = t;
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 7bec22d..6ff1351 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -59,6 +59,8 @@ 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 *);
struct director {
unsigned magic;
@@ -69,6 +71,7 @@ struct director {
vdi_healthy_f *healthy;
vdi_resolve_f *resolve;
vdi_gethdrs_f *gethdrs;
+ vdi_getbody_f *getbody;
void *priv;
};
@@ -154,6 +157,8 @@ void VBP_Summary(struct cli *cli, const struct vbp_target *vt);
/* cache_dir.c */
int VDI_GetHdr(struct worker *wrk, struct busyobj *bo);
+int VDI_GetBody(const struct director *d, struct worker *wrk,
+ struct busyobj *bo);
struct vbc *VDI_GetFd(const struct director *d, struct worker *wrk,
struct busyobj *);
int VDI_Healthy(const struct director *);
diff --git a/bin/varnishd/cache/cache_dir.c b/bin/varnishd/cache/cache_dir.c
index 639c4b4..a9ad94e 100644
--- a/bin/varnishd/cache/cache_dir.c
+++ b/bin/varnishd/cache/cache_dir.c
@@ -131,6 +131,22 @@ VDI_GetHdr(struct worker *wrk, struct busyobj *bo)
return (d->gethdrs(d, wrk, bo));
}
+/* Setup body fetch --------------------------------------------------*/
+
+int
+VDI_GetBody(const struct director *d, struct worker *wrk, struct busyobj *bo)
+{
+
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
+
+ AZ(d->resolve);
+ AN(d->getbody);
+
+ return (d->getbody(d, wrk, bo));
+}
+
/* Get a connection --------------------------------------------------*/
struct vbc *
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index cc581cf..7ba5852 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -107,7 +107,7 @@ vbf_beresp2obj(struct busyobj *bo)
if (varyl > 0) {
AN(vary);
assert(varyl == VSB_len(vary));
- l += PRNDUP(varyl);
+ l += PRNDUP((intptr_t)varyl);
} else if (varyl < 0) {
/*
* Vary parse error
@@ -593,7 +593,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1);
if (bo->htc->body_status != BS_NONE)
- V1F_Setup_Fetch(bo->vfc, bo->htc);
+ AZ(VDI_GetBody(bo->director_resp, bo->wrk, bo));
/*
* Ready to fetch the body
More information about the varnish-commit
mailing list