[master] e5b0ea597 Revert "vrb: Turn BS_CACHED into a request flag"
Nils Goroll
nils.goroll at uplex.de
Mon Aug 12 13:19:07 UTC 2024
commit e5b0ea5976063e3e8b17118a8463e1309507b16c
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Jul 31 20:19:50 2024 +0200
Revert "vrb: Turn BS_CACHED into a request flag"
This reverts commit 58ed5c9f617d0c11b4cd96f9278e6b5babd833ec.
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 185ed67eb..b56cae814 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -289,15 +289,15 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
bo->ws_bo = WS_Snapshot(bo->ws);
HTTP_Clone(bo->bereq, bo->bereq0);
- if (bo->req->req_body_cached) {
+ if (bo->req->req_body_status->avail == 0) {
+ bo->req = NULL;
+ ObjSetState(bo->wrk, oc, BOS_REQ_DONE);
+ } else if (bo->req->req_body_status == BS_CACHED) {
AN(bo->req->body_oc);
bo->bereq_body = bo->req->body_oc;
HSH_Ref(bo->bereq_body);
bo->req = NULL;
ObjSetState(bo->wrk, oc, BOS_REQ_DONE);
- } else if (bo->req->req_body_status->avail == 0) {
- bo->req = NULL;
- ObjSetState(bo->wrk, oc, BOS_REQ_DONE);
}
return (F_STP_STARTFETCH);
}
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index fa4b4062b..f2c894cc0 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -177,7 +177,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
(uintmax_t)req_bodybytes);
}
- req->req_body_cached = 1;
+ req->req_body_status = BS_CACHED;
return (req_bodybytes);
}
@@ -199,7 +199,7 @@ VRB_Iterate(struct worker *wrk, struct vsl_log *vsl,
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(func);
- if (req->req_body_cached) {
+ if (req->req_body_status == BS_CACHED) {
AN(req->body_oc);
if (ObjIterate(wrk, req->body_oc, priv, func, 0))
return (-1);
@@ -277,13 +277,10 @@ VRB_Free(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- if (req->body_oc == NULL) {
- AZ(req->req_body_cached);
+ if (req->body_oc == NULL)
return;
- }
r = HSH_DerefObjCore(req->wrk, &req->body_oc, 0);
- req->req_body_cached = 0;
// each busyobj may have gained a reference
assert (r >= 0);
@@ -315,13 +312,13 @@ VRB_Cache(struct req *req, ssize_t maxsize)
* where we know we will have no competition or conflicts for the
* updates to req.http.* etc.
*/
- if (req->restarts > 0 && !req->req_body_cached) {
+ if (req->restarts > 0 && req->req_body_status != BS_CACHED) {
VSLb(req->vsl, SLT_VCL_Error,
"req.body must be cached before restarts");
return (-1);
}
- if (req->req_body_cached) {
+ if (req->req_body_status == BS_CACHED) {
AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u));
return (u);
}
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 31929e123..ed97a0110 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -813,7 +813,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
bo->req = req;
bo->wrk = wrk;
/* Unless cached, reqbody is not our job */
- if (!req->req_body_cached)
+ if (req->req_body_status != BS_CACHED)
req->req_body_status = BS_NONE;
SES_Close(req->sp, VDI_Http1Pipe(req, bo));
nxt = REQ_FSM_DONE;
@@ -900,7 +900,6 @@ cnt_recv_prep(struct req *req, const char *ci)
req->client_identity = NULL;
req->storage = NULL;
req->trace = FEATURE(FEATURE_TRACE);
- AZ(req->req_body_cached);
}
req->is_hit = 0;
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index b1918253d..4ea37e1d3 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -119,7 +119,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
V1L_Chunked(wrk);
i = VRB_Iterate(wrk, bo->vsl, bo->req, vbf_iter_req_body, bo);
- if (!bo->req->req_body_cached)
+ if (bo->req->req_body_status != BS_CACHED)
bo->no_retry = "req.body not cached";
if (bo->req->req_body_status == BS_ERROR) {
diff --git a/include/tbl/body_status.h b/include/tbl/body_status.h
index 39c45b4fb..108345c6c 100644
--- a/include/tbl/body_status.h
+++ b/include/tbl/body_status.h
@@ -39,6 +39,7 @@ BODYSTATUS(CHUNKED, chunked, 2, 1, 0)
BODYSTATUS(LENGTH, length, 3, 1, 1)
BODYSTATUS(EOF, eof, 4, 1, 0)
BODYSTATUS(TAKEN, taken, 5, 0, 0)
+BODYSTATUS(CACHED, cached, 6, 2, 1)
#undef BODYSTATUS
/*lint -restore */
diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h
index 282bd92ea..6a9e6acbb 100644
--- a/include/tbl/req_flags.h
+++ b/include/tbl/req_flags.h
@@ -41,7 +41,6 @@ REQ_FLAG(waitinglist, 0, 0, "")
REQ_FLAG(want100cont, 0, 0, "")
REQ_FLAG(late100cont, 0, 0, "")
REQ_FLAG(req_reset, 0, 0, "")
-REQ_FLAG(req_body_cached, 0, 0, "")
#define REQ_BEREQ_FLAG(lower, vcl_r, vcl_w, doc) \
REQ_FLAG(lower, vcl_r, vcl_w, doc)
#include "tbl/req_bereq_flags.h"
More information about the varnish-commit
mailing list