[master] b60c09b struct vfp_ctx init cleanup
Nils Goroll
nils.goroll at uplex.de
Tue Oct 10 10:59:08 UTC 2017
commit b60c09bfa8cc69e3299cf719ff0f9ffe0b61cc3b
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Oct 10 12:49:13 2017 +0200
struct vfp_ctx init cleanup
ensure wrk is always set and, for the backend side, move vfp_ctx setup to a
single place in vbf_stp_startfetch()
Fixes #2453
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index b7c9947..1bd002e 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -136,8 +136,6 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
VRTPRIV_init(bo->privs);
- VFP_Setup(bo->vfc);
-
return (bo);
}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index ca8c89c..c6527e8 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -227,12 +227,8 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
static enum fetch_step
vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
{
- struct vfp_ctx *vfc;
-
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
- vfc = bo->vfc;
- CHECK_OBJ_NOTNULL(vfc, VFP_CTX_MAGIC);
assert(bo->fetch_objcore->boc->state <= BOS_REQ_DONE);
@@ -247,9 +243,6 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
bo->do_esi = 0;
bo->do_stream = 1;
- /* reset fetch processors */
- VFP_Setup(vfc);
-
// XXX: BereqEnd + BereqAcct ?
VSL_ChgId(bo->vsl, "bereq", "retry", VXID_Get(wrk, VSL_BACKENDMARKER));
VSLb_ts_busyobj(bo, "Start", bo->t_prev);
@@ -294,6 +287,13 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
assert(bo->fetch_objcore->boc->state <= BOS_REQ_DONE);
AZ(bo->htc);
+
+ VFP_Setup(bo->vfc, wrk);
+ bo->vfc->bo = bo;
+ bo->vfc->oc = bo->fetch_objcore;
+ bo->vfc->http = bo->beresp;
+ bo->vfc->esi_req = bo->bereq;
+
i = VDI_GetHdr(wrk, bo);
now = W_TIM_real(wrk);
@@ -384,12 +384,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
}
}
- bo->vfc->bo = bo;
- bo->vfc->oc = bo->fetch_objcore;
- bo->vfc->wrk = bo->wrk;
- bo->vfc->http = bo->beresp;
- bo->vfc->esi_req = bo->bereq;
-
VCL_backend_response_method(bo->vcl, wrk, NULL, bo, NULL);
if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) {
@@ -819,11 +813,11 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
assert(wrk->handling == VCL_RET_DELIVER);
- bo->vfc->bo = bo;
- bo->vfc->wrk = bo->wrk;
- bo->vfc->oc = bo->fetch_objcore;
- bo->vfc->http = bo->beresp;
- bo->vfc->esi_req = bo->bereq;
+ assert(bo->vfc->bo == bo);
+ assert(bo->vfc->wrk == bo->wrk);
+ assert(bo->vfc->oc == bo->fetch_objcore);
+ assert(bo->vfc->http == bo->beresp);
+ assert(bo->vfc->esi_req == bo->bereq);
if (vbf_beresp2obj(bo)) {
(void)VFP_Error(bo->vfc, "Could not get storage");
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index dd36a4a..3426f78 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -104,11 +104,12 @@ VFP_Extend(const struct vfp_ctx *vc, ssize_t sz)
*/
void
-VFP_Setup(struct vfp_ctx *vc)
+VFP_Setup(struct vfp_ctx *vc, struct worker *wrk)
{
INIT_OBJ(vc, VFP_CTX_MAGIC);
VTAILQ_INIT(&vc->vfp);
+ vc->wrk = wrk;
}
/**********************************************************************
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 217192b..693ac31 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -92,9 +92,8 @@ cnt_transport(struct worker *wrk, struct req *req)
if (req->req_body_status < REQ_BODY_TAKEN) {
AN(req->transport->req_body != NULL);
- VFP_Setup(req->vfc);
+ VFP_Setup(req->vfc, wrk);
req->vfc->http = req->http;
- req->vfc->wrk = wrk;
req->transport->req_body(req);
}
@@ -979,6 +978,7 @@ CNT_Request(struct worker *wrk, struct req *req)
AN(req->vsl->wid & VSL_CLIENTMARKER);
+ /* wrk can have changed for restarts */
req->vfc->wrk = req->wrk = wrk;
wrk->vsl = req->vsl;
for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) {
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 1dac112..86ea8c1 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -111,7 +111,7 @@ void VFP_Init(void);
enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr);
void VFP_Extend(const struct vfp_ctx *, ssize_t sz);
struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *);
-void VFP_Setup(struct vfp_ctx *vc);
+void VFP_Setup(struct vfp_ctx *vc, struct worker *wrk);
int VFP_Open(struct vfp_ctx *bo);
void VFP_Close(struct vfp_ctx *bo);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 3304664..6c14193 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -203,7 +203,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
htc->doclose = http_DoConnection(hp);
RFC2616_Response_Body(bo->wrk, bo);
- bo->vfc->http = bo->beresp;
+ assert(bo->vfc->http == bo->beresp);
if (bo->htc->body_status != BS_NONE &&
bo->htc->body_status != BS_ERROR)
(void)V1F_Setup_Fetch(bo->vfc, bo->htc);
More information about the varnish-commit
mailing list