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
8c9bc4f5
Commit
8c9bc4f5
authored
Mar 06, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
invert the logic of the vdir blacklist to heathy bitmap
... and name it appropriately
parent
54be487b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
vdir.c
lib/libvmod_directors/vdir.c
+11
-10
vdir.h
lib/libvmod_directors/vdir.h
+1
-1
No files found.
lib/libvmod_directors/vdir.c
View file @
8c9bc4f5
...
...
@@ -66,8 +66,8 @@ vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name,
*
vdp
=
vd
;
AZ
(
pthread_rwlock_init
(
&
vd
->
mtx
,
NULL
));
vd
->
dir
=
VRT_AddDirector
(
ctx
,
m
,
priv
,
"%s"
,
vcl_name
);
vd
->
vbm
=
vbit_new
(
8
);
AN
(
vd
->
vbm
);
vd
->
healthy
=
vbit_new
(
8
);
AN
(
vd
->
healthy
);
}
void
...
...
@@ -81,7 +81,7 @@ vdir_delete(struct vdir **vdp)
free
(
vd
->
backend
);
free
(
vd
->
weight
);
AZ
(
pthread_rwlock_destroy
(
&
vd
->
mtx
));
vbit_destroy
(
vd
->
vbm
);
vbit_destroy
(
vd
->
healthy
);
FREE_OBJ
(
vd
);
}
...
...
@@ -284,17 +284,17 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag,
static
unsigned
vdir_pick_by_weight
(
const
struct
vdir
*
vd
,
double
w
,
const
struct
vbitmap
*
blacklist
)
const
struct
vbitmap
*
healthy
)
{
double
a
=
0
.
0
;
VCL_BACKEND
be
=
NULL
;
unsigned
u
;
AN
(
blacklist
);
AN
(
healthy
);
for
(
u
=
0
;
u
<
vd
->
n_backend
;
u
++
)
{
be
=
vd
->
backend
[
u
];
CHECK_OBJ_NOTNULL
(
be
,
DIRECTOR_MAGIC
);
if
(
vbit_test
(
blacklist
,
u
))
if
(
!
vbit_test
(
healthy
,
u
))
continue
;
a
+=
vd
->
weight
[
u
];
if
(
w
<
a
)
...
...
@@ -315,13 +315,14 @@ vdir_pick_be(VRT_CTX, struct vdir *vd, double w)
vdir_wrlock
(
vd
);
for
(
u
=
0
;
u
<
vd
->
n_backend
;
u
++
)
{
if
(
VRT_Healthy
(
ctx
,
vd
->
backend
[
u
],
NULL
))
{
vbit_
clr
(
vd
->
vbm
,
u
);
vbit_
set
(
vd
->
healthy
,
u
);
tw
+=
vd
->
weight
[
u
];
}
else
vbit_set
(
vd
->
vbm
,
u
);
}
else
{
vbit_clr
(
vd
->
healthy
,
u
);
}
}
if
(
tw
>
0
.
0
)
{
u
=
vdir_pick_by_weight
(
vd
,
w
*
tw
,
vd
->
vbm
);
u
=
vdir_pick_by_weight
(
vd
,
w
*
tw
,
vd
->
healthy
);
assert
(
u
<
vd
->
n_backend
);
be
=
vd
->
backend
[
u
];
CHECK_OBJ_NOTNULL
(
be
,
DIRECTOR_MAGIC
);
...
...
lib/libvmod_directors/vdir.h
View file @
8c9bc4f5
...
...
@@ -38,7 +38,7 @@ struct vdir {
double
*
weight
;
double
total_weight
;
VCL_BACKEND
dir
;
struct
vbitmap
*
vbm
;
struct
vbitmap
*
healthy
;
};
void
vdir_new
(
VRT_CTX
,
struct
vdir
**
vdp
,
const
char
*
vcl_name
,
...
...
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