Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-cluster
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-cluster
Commits
daac1c4e
Unverified
Commit
daac1c4e
authored
Aug 01, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inclusive naming
parent
80abdc61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
44 deletions
+44
-44
vmod_cluster.c
src/vmod_cluster.c
+40
-40
vmod_cluster.vcc
src/vmod_cluster.vcc
+4
-4
No files found.
src/vmod_cluster.c
View file @
daac1c4e
...
@@ -75,9 +75,9 @@ struct vmod_cluster_cluster_param {
...
@@ -75,9 +75,9 @@ struct vmod_cluster_cluster_param {
VCL_BOOL
direct
;
VCL_BOOL
direct
;
VCL_BACKEND
cluster
;
VCL_BACKEND
cluster
;
VCL_BACKEND
real
;
VCL_BACKEND
real
;
int
n
black
;
int
n
deny
;
int
spc
black
;
int
spc
deny
;
VCL_BACKEND
black
list
[];
VCL_BACKEND
deny
list
[];
};
};
struct
vmod_cluster_cluster
{
struct
vmod_cluster_cluster
{
...
@@ -97,13 +97,13 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
...
@@ -97,13 +97,13 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
.
healthy
=
vmod_cluster_healthy
,
.
healthy
=
vmod_cluster_healthy
,
}};
}};
#define param_sz(p, spc) (sizeof(*(p)) + (spc) * sizeof(*(p)->
black
list))
#define param_sz(p, spc) (sizeof(*(p)) + (spc) * sizeof(*(p)->
deny
list))
/*
/*
* return a writable task param struct for the current context
* return a writable task param struct for the current context
* with sufficient space for n
black black
list entries
* with sufficient space for n
deny deny
list entries
*
*
* n
black
:
* n
deny
:
* -1: do not create, return NULL if don't exist
* -1: do not create, return NULL if don't exist
*
*
* spc:
* spc:
...
@@ -111,11 +111,11 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
...
@@ -111,11 +111,11 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
* - in INIT, create on heap
* - in INIT, create on heap
* - else create on workspace
* - else create on workspace
* - otherwise return new object here. Size must be
* - otherwise return new object here. Size must be
* param_sz(..., n
black
)
* param_sz(..., n
deny
)
*/
*/
static
struct
vmod_cluster_cluster_param
*
static
struct
vmod_cluster_cluster_param
*
cluster_task_param_l
(
VRT_CTX
,
struct
vmod_cluster_cluster
*
vc
,
cluster_task_param_l
(
VRT_CTX
,
struct
vmod_cluster_cluster
*
vc
,
int
n
black
,
void
*
spc
)
int
n
deny
,
void
*
spc
)
{
{
struct
vmod_priv
*
task
=
NULL
;
struct
vmod_priv
*
task
=
NULL
;
struct
vmod_cluster_cluster_param
*
p
=
NULL
;
struct
vmod_cluster_cluster_param
*
p
=
NULL
;
...
@@ -153,11 +153,11 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -153,11 +153,11 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
}
}
if
(
n
black
==
-
1
)
if
(
n
deny
==
-
1
)
return
(
p
);
return
(
p
);
if
(
o
&&
n
black
<
o
->
nblack
)
if
(
o
&&
n
deny
<
o
->
ndeny
)
n
black
=
o
->
nblack
;
n
deny
=
o
->
ndeny
;
/*
/*
* make the (new) allocation and copy or return if not required
* make the (new) allocation and copy or return if not required
* if space was provided, we always return it
* if space was provided, we always return it
...
@@ -165,23 +165,23 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -165,23 +165,23 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
spc
)
{
if
(
spc
)
{
p
=
spc
;
p
=
spc
;
if
(
o
)
{
if
(
o
)
{
assert
(
n
black
>=
o
->
nblack
);
assert
(
n
deny
>=
o
->
ndeny
);
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
black
));
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
deny
));
}
}
}
else
if
(
p
&&
n
black
<=
p
->
spcblack
)
{
}
else
if
(
p
&&
n
deny
<=
p
->
spcdeny
)
{
return
(
p
);
return
(
p
);
}
else
{
}
else
{
n
black
=
RUP2
(
nblack
,
2
);
n
deny
=
RUP2
(
ndeny
,
2
);
if
(
ctx
->
method
&
VCL_MET_INIT
)
{
if
(
ctx
->
method
&
VCL_MET_INIT
)
{
p
=
realloc
(
p
,
param_sz
(
p
,
n
black
));
p
=
realloc
(
p
,
param_sz
(
p
,
n
deny
));
AN
(
p
);
AN
(
p
);
vc
->
param
=
p
;
vc
->
param
=
p
;
}
else
{
}
else
{
AN
(
o
);
AN
(
o
);
p
=
WS_Alloc
(
ctx
->
ws
,
param_sz
(
p
,
n
black
));
p
=
WS_Alloc
(
ctx
->
ws
,
param_sz
(
p
,
n
deny
));
if
(
p
==
NULL
)
if
(
p
==
NULL
)
return
(
NULL
);
return
(
NULL
);
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
black
));
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
deny
));
}
}
AN
(
task
);
AN
(
task
);
task
->
priv
=
p
;
task
->
priv
=
p
;
...
@@ -191,7 +191,7 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -191,7 +191,7 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
o
==
NULL
)
if
(
o
==
NULL
)
INIT_OBJ
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
INIT_OBJ
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
p
->
spc
black
=
nblack
;
p
->
spc
deny
=
ndeny
;
return
(
p
);
return
(
p
);
}
}
...
@@ -222,8 +222,8 @@ cluster_deny(VRT_CTX, struct vmod_cluster_cluster_param *p,
...
@@ -222,8 +222,8 @@ cluster_deny(VRT_CTX, struct vmod_cluster_cluster_param *p,
VRT_fail
(
ctx
,
"Can not deny the NULL backend"
);
VRT_fail
(
ctx
,
"Can not deny the NULL backend"
);
return
;
return
;
}
}
assert
(
p
->
n
black
<
p
->
spcblack
);
assert
(
p
->
n
deny
<
p
->
spcdeny
);
p
->
blacklist
[
p
->
nblack
++
]
=
b
;
p
->
denylist
[
p
->
ndeny
++
]
=
b
;
}
}
static
void
static
void
...
@@ -237,13 +237,13 @@ cluster_allow(VRT_CTX, struct vmod_cluster_cluster_param *p,
...
@@ -237,13 +237,13 @@ cluster_allow(VRT_CTX, struct vmod_cluster_cluster_param *p,
VRT_fail
(
ctx
,
"Can not allow the NULL backend"
);
VRT_fail
(
ctx
,
"Can not allow the NULL backend"
);
return
;
return
;
}
}
for
(
i
=
0
;
i
<
p
->
n
black
;
i
++
)
for
(
i
=
0
;
i
<
p
->
n
deny
;
i
++
)
if
(
p
->
black
list
[
i
]
==
b
)
{
if
(
p
->
deny
list
[
i
]
==
b
)
{
p
->
n
black
--
;
p
->
n
deny
--
;
if
(
i
<
p
->
n
black
)
if
(
i
<
p
->
n
deny
)
memmove
(
&
p
->
black
list
[
i
],
memmove
(
&
p
->
deny
list
[
i
],
&
p
->
black
list
[
i
+
1
],
&
p
->
deny
list
[
i
+
1
],
(
p
->
n
black
-
i
)
*
sizeof
(
*
p
->
black
list
));
(
p
->
n
deny
-
i
)
*
sizeof
(
*
p
->
deny
list
));
return
;
return
;
}
}
}
}
...
@@ -256,8 +256,8 @@ cluster_denied(const struct vmod_cluster_cluster_param *p,
...
@@ -256,8 +256,8 @@ cluster_denied(const struct vmod_cluster_cluster_param *p,
int
i
;
int
i
;
CHECK_OBJ_NOTNULL
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
CHECK_OBJ_NOTNULL
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
for
(
i
=
0
;
i
<
p
->
n
black
;
i
++
)
{
for
(
i
=
0
;
i
<
p
->
n
deny
;
i
++
)
{
bl
=
p
->
black
list
[
i
];
bl
=
p
->
deny
list
[
i
];
CHECK_OBJ_NOTNULL
(
bl
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
bl
,
DIRECTOR_MAGIC
);
if
(
bl
==
b
)
if
(
bl
==
b
)
return
(
1
);
return
(
1
);
...
@@ -272,7 +272,7 @@ vmod_cluster__init(VRT_CTX,
...
@@ -272,7 +272,7 @@ vmod_cluster__init(VRT_CTX,
{
{
struct
vmod_cluster_cluster
*
vc
;
struct
vmod_cluster_cluster
*
vc
;
struct
vmod_cluster_cluster_param
*
p
;
struct
vmod_cluster_cluster_param
*
p
;
const
int
n
black
_initial
=
2
;
const
int
n
deny
_initial
=
2
;
AN
(
vcp
);
AN
(
vcp
);
AZ
(
*
vcp
);
AZ
(
*
vcp
);
...
@@ -282,7 +282,7 @@ vmod_cluster__init(VRT_CTX,
...
@@ -282,7 +282,7 @@ vmod_cluster__init(VRT_CTX,
return
;
return
;
}
}
AN
(
vc
);
AN
(
vc
);
p
=
cluster_task_param_l
(
ctx
,
vc
,
n
black
_initial
,
NULL
);
p
=
cluster_task_param_l
(
ctx
,
vc
,
n
deny
_initial
,
NULL
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
FREE_OBJ
(
vc
);
FREE_OBJ
(
vc
);
return
;
return
;
...
@@ -330,7 +330,7 @@ vmod_cluster_deny(VRT_CTX,
...
@@ -330,7 +330,7 @@ vmod_cluster_deny(VRT_CTX,
if
(
cluster_denied
(
pr
,
b
))
if
(
cluster_denied
(
pr
,
b
))
return
;
return
;
pl
=
cluster_task_param_l
(
ctx
,
vc
,
pr
->
n
black
+
1
,
NULL
);
pl
=
cluster_task_param_l
(
ctx
,
vc
,
pr
->
n
deny
+
1
,
NULL
);
cluster_deny
(
ctx
,
pl
,
b
);
cluster_deny
(
ctx
,
pl
,
b
);
}
}
...
@@ -349,7 +349,7 @@ vmod_cluster_allow(VRT_CTX,
...
@@ -349,7 +349,7 @@ vmod_cluster_allow(VRT_CTX,
if
(
!
cluster_denied
(
pr
,
b
))
if
(
!
cluster_denied
(
pr
,
b
))
return
;
return
;
pl
=
cluster_task_param_l
(
ctx
,
vc
,
pr
->
n
black
,
NULL
);
pl
=
cluster_task_param_l
(
ctx
,
vc
,
pr
->
n
deny
,
NULL
);
cluster_allow
(
ctx
,
pl
,
b
);
cluster_allow
(
ctx
,
pl
,
b
);
}
}
...
@@ -518,14 +518,14 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -518,14 +518,14 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
void
*
spc
)
void
*
spc
)
{
{
struct
vmod_cluster_cluster_param
*
pl
=
NULL
;
struct
vmod_cluster_cluster_param
*
pl
=
NULL
;
int
n
black
;
int
n
deny
;
CHECK_OBJ_NOTNULL
(
pr
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
CHECK_OBJ_NOTNULL
(
pr
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
n
black
=
pr
->
nblack
;
n
deny
=
pr
->
ndeny
;
if
(
arg
->
valid_deny
&&
arg
->
deny
!=
NULL
&&
if
(
arg
->
valid_deny
&&
arg
->
deny
!=
NULL
&&
!
cluster_denied
(
pr
,
arg
->
deny
))
{
!
cluster_denied
(
pr
,
arg
->
deny
))
{
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
++
n
black
,
spc
);
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
++
n
deny
,
spc
);
if
(
pl
==
NULL
)
if
(
pl
==
NULL
)
return
(
NULL
);
return
(
NULL
);
cluster_deny
(
ctx
,
pl
,
arg
->
deny
);
cluster_deny
(
ctx
,
pl
,
arg
->
deny
);
...
@@ -533,7 +533,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -533,7 +533,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
AN
(
pr
);
AN
(
pr
);
if
(
arg
->
valid_real
&&
pr
->
real
!=
arg
->
real
)
{
if
(
arg
->
valid_real
&&
pr
->
real
!=
arg
->
real
)
{
if
(
pl
==
NULL
)
if
(
pl
==
NULL
)
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
n
black
,
spc
);
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
n
deny
,
spc
);
if
(
pl
==
NULL
)
if
(
pl
==
NULL
)
return
(
NULL
);
return
(
NULL
);
pl
->
real
=
arg
->
real
;
pl
->
real
=
arg
->
real
;
...
@@ -542,7 +542,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
...
@@ -542,7 +542,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
arg
->
valid_uncacheable_direct
&&
if
(
arg
->
valid_uncacheable_direct
&&
pr
->
uncacheable_direct
!=
arg
->
uncacheable_direct
)
{
pr
->
uncacheable_direct
!=
arg
->
uncacheable_direct
)
{
if
(
pl
==
NULL
)
if
(
pl
==
NULL
)
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
n
black
,
spc
);
pr
=
pl
=
cluster_task_param_l
(
ctx
,
vc
,
n
deny
,
spc
);
if
(
pl
==
NULL
)
if
(
pl
==
NULL
)
return
(
NULL
);
return
(
NULL
);
pl
->
uncacheable_direct
=
arg
->
uncacheable_direct
;
pl
->
uncacheable_direct
=
arg
->
uncacheable_direct
;
...
@@ -583,7 +583,7 @@ cluster_choose(VRT_CTX,
...
@@ -583,7 +583,7 @@ cluster_choose(VRT_CTX,
pr
=
cluster_task_param_r
(
ctx
,
vc
);
pr
=
cluster_task_param_r
(
ctx
,
vc
);
CHECK_OBJ_NOTNULL
(
pr
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
CHECK_OBJ_NOTNULL
(
pr
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
char
pstk
[
param_sz
(
pr
,
pr
->
n
black
+
1
)];
char
pstk
[
param_sz
(
pr
,
pr
->
n
deny
+
1
)];
if
((
ctx
->
method
&
cluster_methods
)
==
0
)
if
((
ctx
->
method
&
cluster_methods
)
==
0
)
spc
=
pstk
;
spc
=
pstk
;
...
...
src/vmod_cluster.vcc
View file @
daac1c4e
...
@@ -127,7 +127,7 @@ Instantiate a cluster director on top of the director passed as the
...
@@ -127,7 +127,7 @@ Instantiate a cluster director on top of the director passed as the
`cluster` argument.
`cluster` argument.
The optional `deny` argument allows to specify one backend for which
The optional `deny` argument allows to specify one backend for which
the cluster director will resolve to a `real` backend (the
black
list)
the cluster director will resolve to a `real` backend (the
deny
list)
as if the :ref:`func_cluster.deny` method had been called.
as if the :ref:`func_cluster.deny` method had been called.
The optional `real` argument allows to specify the director which use
The optional `real` argument allows to specify the director which use
...
@@ -142,7 +142,7 @@ disables special handling of uncacheable backend requests.
...
@@ -142,7 +142,7 @@ disables special handling of uncacheable backend requests.
$Method VOID .deny(BACKEND)
$Method VOID .deny(BACKEND)
Add a backend to the list of backends for which the cluster director
Add a backend to the list of backends for which the cluster director
will resolve to a `real` backend (the
black
list).
will resolve to a `real` backend (the
deny
list).
$Restrict vcl_init vcl_backend_fetch
$Restrict vcl_init vcl_backend_fetch
...
@@ -151,7 +151,7 @@ See :ref:`meth_ctx` for limitations.
...
@@ -151,7 +151,7 @@ See :ref:`meth_ctx` for limitations.
$Method VOID .allow(BACKEND)
$Method VOID .allow(BACKEND)
Remove a backend to the list of backends for which the cluster
Remove a backend to the list of backends for which the cluster
director will resolve to a `real` backend (the
black
list).
director will resolve to a `real` backend (the
deny
list).
$Restrict vcl_init vcl_backend_fetch
$Restrict vcl_init vcl_backend_fetch
...
@@ -160,7 +160,7 @@ See :ref:`meth_ctx` for limitations.
...
@@ -160,7 +160,7 @@ See :ref:`meth_ctx` for limitations.
$Method BOOL .is_denied(BACKEND)
$Method BOOL .is_denied(BACKEND)
Return true if the argument is on list of backends for which the
Return true if the argument is on list of backends for which the
cluster director will resolve to a `real` backend (the
black
list).
cluster director will resolve to a `real` backend (the
deny
list).
$Restrict vcl_init vcl_backend_fetch
$Restrict vcl_init vcl_backend_fetch
...
...
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