Commit bb9d7d6f authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Reza Naghibi

Fetch thread reference count and keep cached request bodies

With this patch fetch threads will for completely cached request bodies
keep a reference to it for the entire duration of the fetch. This extends
the retry window of backend requests with request body beyond the
BOS_REQ_DONE point.

Patch by: Poul-Henning Kamp
parent a45e1f4e
......@@ -403,6 +403,7 @@ struct busyobj {
struct http *bereq0;
struct http *bereq;
struct http *beresp;
struct objcore *bereq_body;
struct objcore *stale_oc;
struct objcore *fetch_objcore;
......
......@@ -246,6 +246,12 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
if (bo->req->req_body_status == REQ_BODY_NONE) {
bo->req = NULL;
ObjSetState(bo->wrk, bo->fetch_objcore, BOS_REQ_DONE);
} else if (bo->req->req_body_status == REQ_BODY_CACHED) {
AN(bo->req->body_oc);
bo->bereq_body = bo->req->body_oc;
HSH_Ref(bo->bereq_body);
bo->req = NULL;
ObjSetState(bo->wrk, bo->fetch_objcore, BOS_REQ_DONE);
}
return (F_STP_STARTFETCH);
}
......@@ -1019,6 +1025,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
VCL_TaskLeave(bo->vcl, bo->privs);
http_Teardown(bo->bereq);
http_Teardown(bo->beresp);
if (bo->bereq_body != NULL)
HSH_DerefObjCore(bo->wrk, &bo->bereq_body, 0);
if (bo->fetch_objcore->boc->state == BOS_FINISHED) {
AZ(bo->fetch_objcore->flags & OC_F_FAILED);
......
......@@ -105,7 +105,14 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
/* Deal with any message-body the request might (still) have */
i = 0;
if (bo->req != NULL &&
if (bo->bereq_body != NULL) {
if (do_chunked)
V1L_Chunked(wrk);
(void)ObjIterate(bo->wrk, bo->bereq_body,
bo, vbf_iter_req_body, 0);
if (do_chunked)
V1L_EndChunk(wrk);
} else if (bo->req != NULL &&
(bo->req->req_body_status == REQ_BODY_CACHED || !onlycached)) {
if (do_chunked)
V1L_Chunked(wrk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment