[master] 733905cec vsc: More reactive readiness check after mapping

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Jul 3 10:04:05 UTC 2024


commit 733905ceca55cfc4905901cbbc80d8977e59efba
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Jun 3 22:07:14 2024 +0200

    vsc: More reactive readiness check after mapping
    
    Better diff with the --ignore-all-space option.

diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 26335a715..6229b8d86 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -387,6 +387,7 @@ vsc_map_seg(const struct vsc *vsc, struct vsm *vsm, struct vsc_seg *sp)
 	struct vjsn_val *vv, *vve;
 	struct vsb *vsb;
 	struct vsc_pt *pp;
+	int retry;
 
 	CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC);
 	AN(vsm);
@@ -400,17 +401,18 @@ vsc_map_seg(const struct vsc *vsc, struct vsm *vsm, struct vsc_seg *sp)
 	if (VSM_Map(vsm, sp->fantom))
 		return (-1);
 	head = sp->fantom->b;
+
+	/* It isn't ready yet. Sleep and try again. If it still
+	 * isn't ready, fail the mapping. The transitions inside
+	 * varnishd that we are waiting for are just some memcpy()
+	 * operations, so there is no reason to allow a long retry
+	 * time. */
+	for (retry = 10; retry > 0 && head->ready == 0; retry--)
+		usleep(10000);
+
 	if (head->ready == 0) {
-		/* It isn't ready yet. Sleep and try again. If it still
-		 * isn't ready, fail the mapping. The transitions inside
-		 * varnishd that we are waiting for are just some memcpy()
-		 * operations, so there is no reason to allow a long retry
-		 * time. */
-		usleep(100000);
-		if (head->ready == 0) {
-			VSM_Unmap(vsm, sp->fantom);
-			return (-1);
-		}
+		VSM_Unmap(vsm, sp->fantom);
+		return (-1);
 	}
 
 	sp->head = head;


More information about the varnish-commit mailing list