Mailing List Archive

[master] 2d494dc7c In transport delivery functions, close VDPs always
commit 2d494dc7c6b3adb53c7679ba13929ffa530aa8b5
Author: Nils Goroll <nils.goroll@uplex.de>
Date: Wed Feb 28 13:48:17 2024 +0100

In transport delivery functions, close VDPs always

Part 1 of the fix for #4067

diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 936191ea3..dd921c0f9 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -850,6 +850,17 @@ static const struct vdp ved_ved = {
.fini = ved_vdp_fini,
};

+static void
+ved_close(struct req *req, struct boc *boc, int error)
+{
+ req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc);
+
+ if (! error)
+ return;
+ req->top->topreq->vdc->retval = -1;
+ req->top->topreq->doclose = req->doclose;
+}
+
/*--------------------------------------------------------------------*/

static void v_matchproto_(vtr_deliver_f)
@@ -868,19 +879,22 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)

CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC);

- if (wantbody == 0)
+ if (wantbody == 0) {
+ ved_close(req, boc, 0);
return;
+ }

status = req->resp->status % 1000;

if (!ecx->incl_cont && status != 200 && status != 204) {
- req->top->topreq->vdc->retval = -1;
- req->top->topreq->doclose = req->doclose;
+ ved_close(req, boc, 1);
return;
}

- if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0)
+ if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0) {
+ ved_close(req, boc, 0);
return;
+ }

if (http_GetHdr(req->resp, H_Content_Encoding, &p))
i = http_coding_eq(p, gzip);
@@ -899,7 +913,10 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)

if (req->objcore->flags & OC_F_FAILED) {
/* No way of signalling errors in the middle of
- the ESI body. Omit this ESI fragment. */
+ * the ESI body. Omit this ESI fragment.
+ * XXX change error argument to 1
+ */
+ ved_close(req, boc, 0);
return;
}

@@ -926,10 +943,5 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
if (i && req->doclose == SC_NULL)
req->doclose = SC_REM_CLOSE;

- req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc);
-
- if (i && !ecx->incl_cont) {
- req->top->topreq->vdc->retval = -1;
- req->top->topreq->doclose = req->doclose;
- }
+ ved_close(req, boc, i && !ecx->incl_cont);
}
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index d82443367..15bc706b9 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -40,7 +40,7 @@
/*--------------------------------------------------------------------*/

static void
-v1d_error(struct req *req, const char *msg)
+v1d_error(struct req *req, struct boc *boc, const char *msg)
{
static const char r_500[] =
"HTTP/1.1 500 Internal Server Error\r\n"
@@ -57,6 +57,8 @@ v1d_error(struct req *req, const char *msg)
req->wrk->stats->client_resp_500++;
VTCP_Assert(write(req->sp->fd, r_500, sizeof r_500 - 1));
req->doclose = SC_TX_EOF;
+
+ req->acct.resp_bodybytes += VDP_Close(req->vdc, req->objcore, boc);
}

/*--------------------------------------------------------------------
@@ -98,18 +100,18 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
INIT_OBJ(ctx, VRT_CTX_MAGIC);
VCL_Req2Ctx(ctx, req);
if (VDP_Push(ctx, req->vdc, req->ws, VDP_v1l, NULL)) {
- v1d_error(req, "Failure to push v1d processor");
+ v1d_error(req, boc, "Failure to push v1d processor");
return;
}
}

if (WS_Overflowed(req->ws)) {
- v1d_error(req, "workspace_client overflow");
+ v1d_error(req, boc, "workspace_client overflow");
return;
}

if (WS_Overflowed(req->sp->ws)) {
- v1d_error(req, "workspace_session overflow");
+ v1d_error(req, boc, "workspace_session overflow");
return;
}

@@ -118,7 +120,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
cache_param->http1_iovs);

if (WS_Overflowed(req->wrk->aws)) {
- v1d_error(req, "workspace_thread overflow");
+ v1d_error(req, boc, "workspace_thread overflow");
return;
}

_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit