[master] 0659213 Remove layer-breaking up-calls to VDI_Finish() and make VBE Do The Right Thing instead.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Nov 3 11:06:30 CET 2014
commit 0659213076e177bfba810f316d2b7abfb07541e5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Nov 3 10:05:31 2014 +0000
Remove layer-breaking up-calls to VDI_Finish() and make VBE Do The
Right Thing instead.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 0befb29..8454f56 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -384,6 +384,39 @@ vbe_dir_healthy(const struct director *d, const struct busyobj *bo,
return (VBE_Healthy(be, changed));
}
+static void __match_proto__(vdi_finish_f)
+vbe_dir_finish(const struct director *d, struct worker *wrk,
+ struct busyobj *bo)
+{
+ struct backend *bp;
+
+ CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+
+ CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
+ if (bo->htc->vbc == NULL)
+ return;
+ bp = bo->htc->vbc->backend;
+ if (bo->doclose != SC_NULL) {
+ VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd,
+ bp->display_name);
+ VTCP_close(&bo->htc->vbc->fd);
+ VBE_DropRefConn(bp, &bo->acct);
+ bo->htc->vbc->backend = NULL;
+ VBE_ReleaseConn(bo->htc->vbc);
+ } else {
+ VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->htc->vbc->fd,
+ bp->display_name);
+ Lck_Lock(&bp->mtx);
+ VSC_C_main->backend_recycle++;
+ VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list);
+ VBE_DropRefLocked(bp, &bo->acct);
+ }
+ bo->htc->vbc = NULL;
+ bo->htc = NULL;
+}
+
static int __match_proto__(vdi_gethdrs_f)
vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
struct busyobj *bo)
@@ -408,6 +441,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
* Do a single retry in that case.
*/
if (i == 1) {
+ vbe_dir_finish(d, wrk, bo);
AZ(bo->htc);
VSC_C_main->backend_retry++;
bo->doclose = SC_NULL;
@@ -421,6 +455,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
i = V1F_fetch_hdr(wrk, bo);
}
if (i != 0) {
+ vbe_dir_finish(d, wrk, bo);
bo->doclose = SC_NULL;
AZ(bo->htc);
} else {
@@ -442,39 +477,6 @@ vbe_dir_getbody(const struct director *d, struct worker *wrk,
return (0);
}
-static void __match_proto__(vdi_finish_f)
-vbe_dir_finish(const struct director *d, struct worker *wrk,
- struct busyobj *bo)
-{
- struct backend *bp;
-
- CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-
- CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
- if (bo->htc->vbc == NULL)
- return;
- bp = bo->htc->vbc->backend;
- if (bo->doclose != SC_NULL) {
- VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd,
- bp->display_name);
- VTCP_close(&bo->htc->vbc->fd);
- VBE_DropRefConn(bp, &bo->acct);
- bo->htc->vbc->backend = NULL;
- VBE_ReleaseConn(bo->htc->vbc);
- } else {
- VSLb(bo->vsl, SLT_BackendReuse, "%d %s", bo->htc->vbc->fd,
- bp->display_name);
- Lck_Lock(&bp->mtx);
- VSC_C_main->backend_recycle++;
- VTAILQ_INSERT_HEAD(&bp->connlist, bo->htc->vbc, list);
- VBE_DropRefLocked(bp, &bo->acct);
- }
- bo->htc->vbc = NULL;
- bo->htc = NULL;
-}
-
static struct suckaddr * __match_proto__(vdi_suckaddr_f)
vbe_dir_suckaddr(const struct director *d, struct worker *wrk,
struct busyobj *bo)
diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c
index 0df939e..3a1961a 100644
--- a/bin/varnishd/cache/cache_director.c
+++ b/bin/varnishd/cache/cache_director.c
@@ -100,6 +100,7 @@ VDI_GetBody(const struct director *d, struct worker *wrk, struct busyobj *bo)
AZ(d->resolve);
AN(d->getbody);
+ assert(bo->director_state == DIR_S_HDRS);
bo->director_state = DIR_S_BODY;
return (d->getbody(d, wrk, bo));
}
@@ -118,9 +119,8 @@ VDI_Finish(const struct director *d, struct worker *wrk, struct busyobj *bo)
AN(d->finish);
assert(bo->director_state != DIR_S_NULL);
- bo->director_state = DIR_S_NULL;
-
d->finish(d, wrk, bo);
+ bo->director_state = DIR_S_NULL;
}
/* Get a connection --------------------------------------------------*/
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 58175b4..ac5448c 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -141,8 +141,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
errno, strerror(errno));
VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk));
bo->doclose = SC_TX_ERROR;
- VDI_Finish(bo->director_resp, bo->wrk, bo);
- /* XXX: other cleanup ? */
return (retry);
}
VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk));
@@ -168,8 +166,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
"http %sread error: overflow",
first ? "first " : "");
bo->doclose = SC_RX_OVERFLOW;
- VDI_Finish(bo->director_resp, bo->wrk, bo);
- /* XXX: other cleanup ? */
return (-1);
}
if (hs == HTTP1_ERROR_EOF) {
@@ -178,8 +174,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF",
first ? "first " : "");
bo->doclose = SC_RX_TIMEOUT;
- VDI_Finish(bo->director_resp, bo->wrk, bo);
- /* XXX: other cleanup ? */
return (retry);
}
if (first) {
@@ -196,8 +190,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
if (HTTP1_DissectResponse(hp, htc)) {
VSLb(bo->vsl, SLT_FetchError, "http format error");
bo->doclose = SC_RX_JUNK;
- VDI_Finish(bo->director_resp, bo->wrk, bo);
- /* XXX: other cleanup ? */
return (-1);
}
More information about the varnish-commit
mailing list