I'm on the train with shitty connectivity, so I will not attempt a pull request, but this is a proposed DTRT patch for 3093
(Note that the vtc in 3093 fails, because this DTRT) Comments & Tests welcome. Spotted along the way: Should we alloc std.cache_req_body() also in vcl_backend_fetch{} ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 p...@freebsd.org | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 778db6861..c27745d71 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -407,6 +407,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 38a25d6dd..a98ffce1e 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); } @@ -924,6 +930,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); diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 13c4ed07f..4cdaff865 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -233,7 +233,7 @@ VRB_Iterate(struct req *req, objiterate_f *func, void *priv) */ static int v_matchproto_(objiterate_f) -httpq_req_body_discard(void *priv, unsigned flush, const void *ptr, ssize_t len) +httpq_re_body_discard(void *priv, unsigned flush, const void *ptr, ssize_t len) { (void)priv; diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index dc1515ef1..b8dd44c7c 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);
_______________________________________________ varnish-dev mailing list varnish-dev@varnish-cache.org https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev