[master] d4b6228e1 Fetch thread reference count and keep cached request bodies
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Jan 15 15:02:06 UTC 2020
commit d4b6228e1e32cda3014eeff0a5cb60cd7a0b5474
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Mon Nov 4 11:32:59 2019 +0100
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
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f45e9f1d2..836be9c4e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index a8bede008..808655f0b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -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);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index b2882ab3a..30d03d469 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -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);
More information about the varnish-commit
mailing list