[master] 92f3d07 Try adding a memory barrier on the varnishd side, and use the JSON offset as canary on the API side.

Poul-Henning Kamp phk at FreeBSD.org
Sun Jun 11 22:39:05 CEST 2017


commit 92f3d075bc9bb561492d522ffb9e17d8018e0f19
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Jun 11 20:37:57 2017 +0000

    Try adding a memory barrier on the varnishd side, and use the JSON offset
    as canary on the API side.

diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c
index 6157c8c..00a1ab0 100644
--- a/bin/varnishd/common/common_vsc.c
+++ b/bin/varnishd/common/common_vsc.c
@@ -39,6 +39,7 @@
 
 #include "vend.h"
 #include "vgz.h"
+#include "vmb.h"
 #include "vapi/vsc_int.h"
 
 /*--------------------------------------------------------------------*/
@@ -79,7 +80,6 @@ VSC_Alloc(const char *nm, size_t sd,
 	AN(p);
 
 	memset(p, 0, sd);
-	vbe64enc(p, sd);
 
 	memset(&vz, 0, sizeof vz);
 	assert(Z_OK == inflateInit2(&vz, 31));
@@ -94,6 +94,8 @@ VSC_Alloc(const char *nm, size_t sd,
 	vsg->seg = p;
 	vsg->ptr = p + 8;
 	VTAILQ_INSERT_TAIL(&vsc_seglist, vsg, list);
+	VWMB();
+	vbe64enc(p, sd);
 	return (p + 8);
 }
 
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 1efb4c4..79b431e 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -37,6 +37,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "vdef.h"
 #include "vas.h"
@@ -300,6 +301,11 @@ vsc_build_vf_list(struct vsm *vd)
 			continue;
 		AZ(VSM_Map(vd, &vsc->iter_fantom));
 		u = vbe64dec(vsc->iter_fantom.b);
+		if (u == 0) {
+			VRMB();
+			usleep(100000);
+			u = vbe64dec(vsc->iter_fantom.b);
+		}
 		assert(u > 0);
 		p = (char*)vsc->iter_fantom.b + 8 + u;
 		vj = vjsn_parse(p, &e);



More information about the varnish-commit mailing list