Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
0f0c8b87
Commit
0f0c8b87
authored
Sep 12, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Umap and free all segments on VSM_Destroy()
Fixes #2416
parent
c6999ca3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
18 deletions
+50
-18
vsm.c
lib/libvarnishapi/vsm.c
+50
-18
No files found.
lib/libvarnishapi/vsm.c
View file @
0f0c8b87
...
...
@@ -147,6 +147,44 @@ vsm_diag(struct vsm *vd, const char *fmt, ...)
/*--------------------------------------------------------------------*/
static
void
vsm_unmapseg
(
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
=
vg
->
e
=
NULL
;
}
/*--------------------------------------------------------------------*/
static
void
vsm_delseg
(
struct
vsm_seg
*
vg
)
{
CHECK_OBJ_NOTNULL
(
vg
,
VSM_SEG_MAGIC
);
if
(
vg
->
b
!=
NULL
)
vsm_unmapseg
(
vg
);
if
(
vg
->
stale
)
VTAILQ_REMOVE
(
&
vg
->
set
->
stale
,
vg
,
list
);
else
VTAILQ_REMOVE
(
&
vg
->
set
->
segs
,
vg
,
list
);
VAV_Free
(
vg
->
av
);
FREE_OBJ
(
vg
);
}
/*--------------------------------------------------------------------*/
static
struct
vsm_set
*
vsm_newset
(
const
char
*
dirname
)
{
...
...
@@ -173,7 +211,10 @@ vsm_delset(struct vsm_set **p)
closefd
(
&
vs
->
fd
);
if
(
vs
->
dfd
>=
0
)
closefd
(
&
vs
->
dfd
);
// XXX: delete segments
while
(
!
VTAILQ_EMPTY
(
&
vs
->
stale
))
vsm_delseg
(
VTAILQ_FIRST
(
&
vs
->
stale
));
while
(
!
VTAILQ_EMPTY
(
&
vs
->
segs
))
vsm_delseg
(
VTAILQ_FIRST
(
&
vs
->
segs
));
FREE_OBJ
(
vs
);
}
...
...
@@ -243,11 +284,13 @@ VSM_Destroy(struct vsm **vdp)
TAKE_OBJ_NOTNULL
(
vd
,
vdp
,
VSM_MAGIC
);
VSM_ResetError
(
vd
);
free
(
vd
->
dname
);
vsm_delset
(
&
vd
->
mgt
);
vsm_delset
(
&
vd
->
child
);
REPLACE
(
vd
->
dname
,
NULL
);
if
(
vd
->
diag
!=
NULL
)
VSB_destroy
(
&
vd
->
diag
);
if
(
vd
->
dfd
>=
0
)
closefd
(
&
vd
->
dfd
);
vsm_delset
(
&
vd
->
mgt
);
vsm_delset
(
&
vd
->
child
);
FREE_OBJ
(
vd
);
}
...
...
@@ -699,7 +742,6 @@ 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
);
...
...
@@ -714,19 +756,9 @@ 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
);
}
vsm_unmapseg
(
vg
);
if
(
vg
->
stale
)
vsm_delseg
(
vg
);
return
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment