[master] b0dcf6b90 V1L: Make workspace rollback optional
Nils Goroll
nils.goroll at uplex.de
Wed Feb 5 09:14:05 UTC 2025
commit b0dcf6b901413d78f93d2aad9f92b0327d02c466
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Feb 5 10:07:42 2025 +0100
V1L: Make workspace rollback optional
When we changed V1L to also be able to use other workspaces than the thread
workspace (aws), we (me) overlooked that the rollback in V1L_Close() can only
work with the aws and only makes sense for the aws.
So to support new use cases where V1L outlives the worker thread, we need to
make the rollback optional. As long as the new use case is the exception,
specifically preventing it without changing the rest of the API seems to be the
least intrusive.
Ref 8c872002c75c9dd38c5f114720dd5f893449a03c
Ref febfce2ad87d218c6345e343fd712442e86b6c15
Spotted by ws_emu aka workspace SAN https://app.circleci.com/pipelines/github/varnishcache/varnish-cache/6655/workflows/cb155a57-c1f7-4bc1-885c-0a8432613319/jobs/86172
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index 85203295f..d9b8f4405 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -63,6 +63,7 @@ void V1L_Chunked(struct v1l *v1l);
void V1L_EndChunk(struct v1l *v1l);
struct v1l * V1L_Open(struct ws *, int *fd, struct vsl_log *,
vtim_real deadline, unsigned niov);
+void V1L_NoRollback(struct v1l *v1l);
stream_close_t V1L_Flush(struct v1l *v1l);
stream_close_t V1L_Close(struct v1l **v1lp, uint64_t *cnt);
size_t V1L_Write(struct v1l *v1l, const void *ptr, ssize_t len);
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index d19fb4f08..abf853ae2 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -126,6 +126,14 @@ V1L_Open(struct ws *ws, int *fd, struct vsl_log *vsl,
return (v1l);
}
+void
+V1L_NoRollback(struct v1l *v1l)
+{
+
+ CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC);
+ v1l->ws_snap = 0;
+}
+
stream_close_t
V1L_Close(struct v1l **v1lp, uint64_t *cnt)
{
@@ -145,7 +153,8 @@ V1L_Close(struct v1l **v1lp, uint64_t *cnt)
ws = v1l->ws;
ws_snap = v1l->ws_snap;
ZERO_OBJ(v1l, sizeof *v1l);
- WS_Rollback(ws, ws_snap);
+ if (ws_snap != 0)
+ WS_Rollback(ws, ws_snap);
return (sc);
}
diff --git a/vmod/vmod_debug_transport_reembarking_http1.c b/vmod/vmod_debug_transport_reembarking_http1.c
index 32e176ab3..0c5dcffaf 100644
--- a/vmod/vmod_debug_transport_reembarking_http1.c
+++ b/vmod/vmod_debug_transport_reembarking_http1.c
@@ -89,6 +89,9 @@ dbg_deliver(struct req *req, int sendbody)
return (VTR_D_DONE);
}
+ // Do not roll back req->ws upon V1L_Close()
+ V1L_NoRollback(v1l);
+
if (sendbody) {
if (!http_GetHdr(req->resp, H_Content_Length, NULL)) {
if (req->http->protover == 11) {
More information about the varnish-commit
mailing list