[master] a8b3a8b81 Emit a warning if mlock() of VSM fails

Nils Goroll nils.goroll at uplex.de
Mon Aug 19 13:42:04 UTC 2024


commit a8b3a8b812acc4eae5f30222bd5f80e7ad7bf6e4
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Aug 12 16:01:57 2024 +0200

    Emit a warning if mlock() of VSM fails

diff --git a/bin/varnishd/common/common_vsmw.c b/bin/varnishd/common/common_vsmw.c
index 1e0710996..3a9aeb001 100644
--- a/bin/varnishd/common/common_vsmw.c
+++ b/bin/varnishd/common/common_vsmw.c
@@ -278,6 +278,7 @@ static struct vsmw_cluster *
 vsmw_newcluster(struct vsmw *vsmw, size_t len, const char *pfx)
 {
 	struct vsmw_cluster *vc;
+	static int warn = 0;
 	int fd;
 	size_t ps;
 
@@ -307,7 +308,10 @@ vsmw_newcluster(struct vsmw *vsmw, size_t len, const char *pfx)
 
 	closefd(&fd);
 	assert(vc->ptr != MAP_FAILED);
-	(void)mlock(vc->ptr, len);
+	if (mlock(vc->ptr, len) && warn++ == 0)  {
+		fprintf(stderr, "Warning: mlock() of VSM failed: %s (%d)\n",
+		    VAS_errtxt(errno), errno);
+	}
 
 	return (vc);
 }


More information about the varnish-commit mailing list