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
2cbf11f8
Commit
2cbf11f8
authored
Apr 24, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish the health check a bit.
parent
705e38b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
18 deletions
+11
-18
cache_backend.c
bin/varnishd/cache/cache_backend.c
+11
-18
No files found.
bin/varnishd/cache/cache_backend.c
View file @
2cbf11f8
...
...
@@ -271,10 +271,10 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req)
{
struct
trouble
*
tr
;
struct
trouble
*
tr2
;
struct
trouble
*
old
;
unsigned
i
=
0
,
retval
;
unsigned
retval
;
unsigned
int
threshold
;
struct
backend
*
backend
;
VTAILQ_HEAD
(,
trouble
)
troublelist
;
double
now
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
...
...
@@ -299,42 +299,35 @@ vbe_Healthy(const struct vdi_simple *vs, const struct req *req)
threshold
=
UINT_MAX
;
/* Saintmode is disabled, or list is empty */
if
(
threshold
==
0
||
VTAILQ_EMPTY
(
&
backend
->
troublelist
)
)
if
(
threshold
==
0
||
backend
->
n_trouble
==
0
)
return
(
1
);
now
=
req
->
t_req
;
old
=
NULL
;
retval
=
1
;
VTAILQ_INIT
(
&
troublelist
);
Lck_Lock
(
&
backend
->
mtx
);
VTAILQ_FOREACH_SAFE
(
tr
,
&
backend
->
troublelist
,
list
,
tr2
)
{
CHECK_OBJ_NOTNULL
(
tr
,
TROUBLE_MAGIC
);
if
(
tr
->
timeout
<
now
)
{
VTAILQ_REMOVE
(
&
backend
->
troublelist
,
tr
,
list
);
old
=
tr
;
retval
=
1
;
break
;
VTAILQ_INSERT_HEAD
(
&
troublelist
,
tr
,
list
)
;
backend
->
n_trouble
--
;
continue
;
}
if
(
!
memcmp
(
tr
->
digest
,
req
->
digest
,
sizeof
tr
->
digest
))
{
retval
=
0
;
break
;
}
/* If the threshold is at 1, a single entry on the list
* will disable the backend. Since 0 is disable, ++i
* instead of i++ to allow this behavior.
*/
if
(
++
i
>=
threshold
)
{
retval
=
0
;
break
;
}
}
if
(
threshold
<=
backend
->
n_trouble
)
retval
=
0
;
Lck_Unlock
(
&
backend
->
mtx
);
if
(
old
!=
NULL
)
FREE_OBJ
(
old
);
VTAILQ_FOREACH_SAFE
(
tr
,
&
troublelist
,
list
,
tr2
)
FREE_OBJ
(
tr
);
return
(
retval
);
}
...
...
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