Permalink
Browse files

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
  • Loading branch information...
nigoroll committed Oct 10, 2017
1 parent c0f7fc3 commit b60c09bfa8cc69e3299cf719ff0f9ffe0b61cc3b
@@ -136,8 +136,6 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
VRTPRIV_init(bo->privs);
VFP_Setup(bo->vfc);
return (bo);
}
@@ -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");
@@ -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;
}
/**********************************************************************
@@ -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; ) {
@@ -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);
@@ -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);

0 comments on commit b60c09b

Please sign in to comment.