[master] 51a82f4 Always unmap in VSM_Unmap when refs reaches zero.
Martin Blix Grydeland
martin at varnish-software.com
Fri Sep 1 10:21:11 CEST 2017
commit 51a82f4bf7018253c7eb2f982f760a338a2de14a
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Thu Aug 31 09:54:27 2017 +0200
Always unmap in VSM_Unmap when refs reaches zero.
Remove the unmap-handling from vsm_refresh_set.
Revert bdd702906d47 "Always munmap(2) segments when we delete them."
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 02d9403..cf7456b 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -302,26 +302,6 @@ VSM_ResetError(struct vsm *vd)
/*--------------------------------------------------------------------
*/
-static void
-vsm_unmap(struct vsm_seg *vg)
-{
- size_t sz, ps, len;
-
- CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC);
- AN(vg->b);
- AN(vg->e);
- sz = strtoul(vg->av[2], NULL, 10);
- assert(sz > 0);
- ps = getpagesize();
- len = RUP2(sz, ps);
- AZ(munmap(vg->b, len));
- vg->b = NULL;
- vg->e = NULL;
-}
-
-/*--------------------------------------------------------------------
- */
-
#define VSM_NUKE_ALL (1U << 16)
static int
@@ -490,8 +470,6 @@ vsm_refresh_set(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
vg->stale = 1;
VTAILQ_INSERT_TAIL(&vs->stale, vg, list);
} else {
- if (vg->b != NULL)
- vsm_unmap(vg);
VAV_Free(vg->av);
FREE_OBJ(vg);
}
@@ -724,6 +702,7 @@ int
VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
{
struct vsm_seg *vg;
+ size_t sz, ps, len;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(vd->attached);
@@ -738,12 +717,18 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
vf->e = NULL;
if (vg->refs > 0)
return(0);
+ AN(vg->b);
+ AN(vg->e);
+ sz = strtoul(vg->av[2], NULL, 10);
+ assert(sz > 0);
+ ps = getpagesize();
+ len = RUP2(sz, ps);
+ AZ(munmap(vg->b, len));
+ vg->b = vg->e = NULL;
if (vg->stale) {
VTAILQ_REMOVE(&vg->set->stale, vg, list);
VAV_Free(vg->av);
FREE_OBJ(vg);
- } else {
- vsm_unmap(vg);
}
return (0);
}
More information about the varnish-commit
mailing list