[master] f7767df01 Ensure vxids are fully written before the memory barrier
Nils Goroll
nils.goroll at uplex.de
Tue Jun 13 16:47:07 UTC 2023
commit f7767df01b0ab17d242c4eeb4d92389a42bfae06
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Jun 13 17:49:25 2023 +0200
Ensure vxids are fully written before the memory barrier
Seen while staring at #3937
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 67150f69a..9c1fefe33 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -273,9 +273,11 @@ vslr(enum VSL_tag_e tag, vxid_t vxid, const char *b, unsigned len)
memcpy(p + VSL_OVERHEAD, b, len);
/*
- * vsl_hdr() writes p[1] again, but we want to make sure it
- * has hit memory because we work on the live buffer here.
+ * the vxid needs to be written before the barrier to
+ * ensure it is valid when vsl_hdr() marks the record
+ * ready by writing p[0]
*/
+ p[2] = vxid.vxid >> 32;
p[1] = vxid.vxid;
VWMB();
(void)vsl_hdr(tag, p, len, vxid);
More information about the varnish-commit
mailing list