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
5902f53e
Commit
5902f53e
authored
Aug 07, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code a bit
parent
c1e9a3ad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
30 deletions
+25
-30
vsm.c
lib/libvarnishapi/vsm.c
+25
-30
No files found.
lib/libvarnishapi/vsm.c
View file @
5902f53e
...
@@ -285,6 +285,25 @@ vsm_delset(struct vsm_set **p)
...
@@ -285,6 +285,25 @@ vsm_delset(struct vsm_set **p)
FREE_OBJ
(
vs
);
FREE_OBJ
(
vs
);
}
}
static
void
vsm_wash_set
(
struct
vsm_set
*
vs
,
int
all
)
{
struct
vsm_seg
*
vg
,
*
vg2
;
VTAILQ_FOREACH_SAFE
(
vg
,
&
vs
->
segs
,
list
,
vg2
)
{
if
(
all
||
(
vg
->
flags
&
VSM_FLAG_MARKSCAN
)
==
0
)
{
VTAILQ_REMOVE
(
&
vs
->
segs
,
vg
,
list
);
if
(
vg
->
refs
)
{
vg
->
flags
|=
VSM_FLAG_STALE
;
VTAILQ_INSERT_TAIL
(
&
vs
->
stale
,
vg
,
list
);
}
else
{
VAV_Free
(
vg
->
av
);
FREE_OBJ
(
vg
);
}
}
}
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
struct
vsm
*
struct
vsm
*
...
@@ -393,8 +412,6 @@ VSM_ResetError(struct vsm *vd)
...
@@ -393,8 +412,6 @@ VSM_ResetError(struct vsm *vd)
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
*/
*/
#define VSM_NUKE_ALL (1U << 16)
static
int
static
int
vsm_cmp_av
(
char
*
const
*
a1
,
char
*
const
*
a2
)
vsm_cmp_av
(
char
*
const
*
a1
,
char
*
const
*
a2
)
{
{
...
@@ -563,7 +580,7 @@ vsm_vlu_func(void *priv, const char *line)
...
@@ -563,7 +580,7 @@ vsm_vlu_func(void *priv, const char *line)
}
}
static
unsigned
static
unsigned
vsm_refresh_set
2
(
struct
vsm
*
vd
,
struct
vsm_set
*
vs
)
vsm_refresh_set
(
struct
vsm
*
vd
,
struct
vsm_set
*
vs
)
{
{
struct
stat
st
;
struct
stat
st
;
int
i
;
int
i
;
...
@@ -576,7 +593,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
...
@@ -576,7 +593,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
if
(
fstatat
(
vd
->
dfd
,
vs
->
dname
,
&
st
,
AT_SYMLINK_NOFOLLOW
))
{
if
(
fstatat
(
vd
->
dfd
,
vs
->
dname
,
&
st
,
AT_SYMLINK_NOFOLLOW
))
{
closefd
(
&
vs
->
dfd
);
closefd
(
&
vs
->
dfd
);
vs
->
id1
=
vs
->
id2
=
0
;
vs
->
id1
=
vs
->
id2
=
0
;
return
(
VSM_MGT_RESTARTED
|
VSM_NUKE_ALL
);
vsm_wash_set
(
vs
,
1
);
return
(
VSM_MGT_RESTARTED
|
VSM_MGT_CHANGED
);
}
}
if
(
st
.
st_ino
!=
vs
->
dst
.
st_ino
||
if
(
st
.
st_ino
!=
vs
->
dst
.
st_ino
||
st
.
st_dev
!=
vs
->
dst
.
st_dev
||
st
.
st_dev
!=
vs
->
dst
.
st_dev
||
...
@@ -593,7 +611,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
...
@@ -593,7 +611,8 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
vs
->
retval
|=
VSM_MGT_RESTARTED
;
vs
->
retval
|=
VSM_MGT_RESTARTED
;
if
(
vs
->
dfd
<
0
)
{
if
(
vs
->
dfd
<
0
)
{
vs
->
id1
=
vs
->
id2
=
0
;
vs
->
id1
=
vs
->
id2
=
0
;
return
(
vs
->
retval
|
VSM_NUKE_ALL
);
vsm_wash_set
(
vs
,
1
);
return
(
vs
->
retval
|
VSM_MGT_CHANGED
);
}
}
AZ
(
fstat
(
vs
->
dfd
,
&
vs
->
dst
));
AZ
(
fstat
(
vs
->
dfd
,
&
vs
->
dst
));
}
}
...
@@ -631,34 +650,10 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
...
@@ -631,34 +650,10 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs)
}
while
(
!
i
);
}
while
(
!
i
);
assert
(
i
==
-
2
);
assert
(
i
==
-
2
);
VLU_Destroy
(
&
vlu
);
VLU_Destroy
(
&
vlu
);
vsm_wash_set
(
vs
,
0
);
return
(
vs
->
retval
);
return
(
vs
->
retval
);
}
}
static
unsigned
vsm_refresh_set
(
struct
vsm
*
vd
,
struct
vsm_set
*
vs
)
{
unsigned
retval
;
struct
vsm_seg
*
vg
,
*
vg2
;
retval
=
vsm_refresh_set2
(
vd
,
vs
);
if
(
retval
&
VSM_NUKE_ALL
)
retval
|=
VSM_MGT_CHANGED
;
VTAILQ_FOREACH_SAFE
(
vg
,
&
vs
->
segs
,
list
,
vg2
)
{
if
((
vg
->
flags
&
VSM_FLAG_MARKSCAN
)
==
0
||
(
retval
&
VSM_NUKE_ALL
))
{
VTAILQ_REMOVE
(
&
vs
->
segs
,
vg
,
list
);
if
(
vg
->
refs
)
{
vg
->
flags
|=
VSM_FLAG_STALE
;
VTAILQ_INSERT_TAIL
(
&
vs
->
stale
,
vg
,
list
);
}
else
{
VAV_Free
(
vg
->
av
);
FREE_OBJ
(
vg
);
}
}
}
return
(
retval
&
~
VSM_NUKE_ALL
);
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
unsigned
unsigned
...
...
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