Commit d4b6228e authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Dridi Boukelmoune

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 eb14a0b6
......@@ -401,6 +401,7 @@ struct busyobj {
struct http *bereq0;
struct http *bereq;
struct http *beresp;
struct objcore *bereq_body;
struct objcore *stale_oc;
struct objcore *fetch_objcore;
......
......@@ -241,6 +241,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);
}
......@@ -969,6 +975,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
VCL_TaskLeave(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);
......
......@@ -104,7 +104,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