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 {
VCL_BOOL
direct
;
VCL_BACKEND
cluster
;
VCL_BACKEND
real
;
int
n
black
;
int
spc
black
;
VCL_BACKEND
black
list
[];
int
n
deny
;
int
spc
deny
;
VCL_BACKEND
deny
list
[];
};
struct
vmod_cluster_cluster
{
...
...
@@ -97,13 +97,13 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
.
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
* 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
*
* spc:
...
...
@@ -111,11 +111,11 @@ static const struct vdi_methods vmod_cluster_methods[1] = {{
* - in INIT, create on heap
* - else create on workspace
* - otherwise return new object here. Size must be
* param_sz(..., n
black
)
* param_sz(..., n
deny
)
*/
static
struct
vmod_cluster_cluster_param
*
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_cluster_cluster_param
*
p
=
NULL
;
...
...
@@ -153,11 +153,11 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
}
if
(
n
black
==
-
1
)
if
(
n
deny
==
-
1
)
return
(
p
);
if
(
o
&&
n
black
<
o
->
nblack
)
n
black
=
o
->
nblack
;
if
(
o
&&
n
deny
<
o
->
ndeny
)
n
deny
=
o
->
ndeny
;
/*
* make the (new) allocation and copy or return if not required
* if space was provided, we always return it
...
...
@@ -165,23 +165,23 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
spc
)
{
p
=
spc
;
if
(
o
)
{
assert
(
n
black
>=
o
->
nblack
);
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
black
));
assert
(
n
deny
>=
o
->
ndeny
);
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
);
}
else
{
n
black
=
RUP2
(
nblack
,
2
);
n
deny
=
RUP2
(
ndeny
,
2
);
if
(
ctx
->
method
&
VCL_MET_INIT
)
{
p
=
realloc
(
p
,
param_sz
(
p
,
n
black
));
p
=
realloc
(
p
,
param_sz
(
p
,
n
deny
));
AN
(
p
);
vc
->
param
=
p
;
}
else
{
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
)
return
(
NULL
);
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
black
));
memcpy
(
p
,
o
,
param_sz
(
o
,
o
->
n
deny
));
}
AN
(
task
);
task
->
priv
=
p
;
...
...
@@ -191,7 +191,7 @@ cluster_task_param_l(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
o
==
NULL
)
INIT_OBJ
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
p
->
spc
black
=
nblack
;
p
->
spc
deny
=
ndeny
;
return
(
p
);
}
...
...
@@ -222,8 +222,8 @@ cluster_deny(VRT_CTX, struct vmod_cluster_cluster_param *p,
VRT_fail
(
ctx
,
"Can not deny the NULL backend"
);
return
;
}
assert
(
p
->
n
black
<
p
->
spcblack
);
p
->
blacklist
[
p
->
nblack
++
]
=
b
;
assert
(
p
->
n
deny
<
p
->
spcdeny
);
p
->
denylist
[
p
->
ndeny
++
]
=
b
;
}
static
void
...
...
@@ -237,13 +237,13 @@ cluster_allow(VRT_CTX, struct vmod_cluster_cluster_param *p,
VRT_fail
(
ctx
,
"Can not allow the NULL backend"
);
return
;
}
for
(
i
=
0
;
i
<
p
->
n
black
;
i
++
)
if
(
p
->
black
list
[
i
]
==
b
)
{
p
->
n
black
--
;
if
(
i
<
p
->
n
black
)
memmove
(
&
p
->
black
list
[
i
],
&
p
->
black
list
[
i
+
1
],
(
p
->
n
black
-
i
)
*
sizeof
(
*
p
->
black
list
));
for
(
i
=
0
;
i
<
p
->
n
deny
;
i
++
)
if
(
p
->
deny
list
[
i
]
==
b
)
{
p
->
n
deny
--
;
if
(
i
<
p
->
n
deny
)
memmove
(
&
p
->
deny
list
[
i
],
&
p
->
deny
list
[
i
+
1
],
(
p
->
n
deny
-
i
)
*
sizeof
(
*
p
->
deny
list
));
return
;
}
}
...
...
@@ -256,8 +256,8 @@ cluster_denied(const struct vmod_cluster_cluster_param *p,
int
i
;
CHECK_OBJ_NOTNULL
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
for
(
i
=
0
;
i
<
p
->
n
black
;
i
++
)
{
bl
=
p
->
black
list
[
i
];
for
(
i
=
0
;
i
<
p
->
n
deny
;
i
++
)
{
bl
=
p
->
deny
list
[
i
];
CHECK_OBJ_NOTNULL
(
bl
,
DIRECTOR_MAGIC
);
if
(
bl
==
b
)
return
(
1
);
...
...
@@ -272,7 +272,7 @@ vmod_cluster__init(VRT_CTX,
{
struct
vmod_cluster_cluster
*
vc
;
struct
vmod_cluster_cluster_param
*
p
;
const
int
n
black
_initial
=
2
;
const
int
n
deny
_initial
=
2
;
AN
(
vcp
);
AZ
(
*
vcp
);
...
...
@@ -282,7 +282,7 @@ vmod_cluster__init(VRT_CTX,
return
;
}
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
)
{
FREE_OBJ
(
vc
);
return
;
...
...
@@ -330,7 +330,7 @@ vmod_cluster_deny(VRT_CTX,
if
(
cluster_denied
(
pr
,
b
))
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
);
}
...
...
@@ -349,7 +349,7 @@ vmod_cluster_allow(VRT_CTX,
if
(
!
cluster_denied
(
pr
,
b
))
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
);
}
...
...
@@ -518,14 +518,14 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
void
*
spc
)
{
struct
vmod_cluster_cluster_param
*
pl
=
NULL
;
int
n
black
;
int
n
deny
;
CHECK_OBJ_NOTNULL
(
pr
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
n
black
=
pr
->
nblack
;
n
deny
=
pr
->
ndeny
;
if
(
arg
->
valid_deny
&&
arg
->
deny
!=
NULL
&&
!
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
)
return
(
NULL
);
cluster_deny
(
ctx
,
pl
,
arg
->
deny
);
...
...
@@ -533,7 +533,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
AN
(
pr
);
if
(
arg
->
valid_real
&&
pr
->
real
!=
arg
->
real
)
{
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
)
return
(
NULL
);
pl
->
real
=
arg
->
real
;
...
...
@@ -542,7 +542,7 @@ cluster_update_by_args(VRT_CTX, struct vmod_cluster_cluster *vc,
if
(
arg
->
valid_uncacheable_direct
&&
pr
->
uncacheable_direct
!=
arg
->
uncacheable_direct
)
{
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
)
return
(
NULL
);
pl
->
uncacheable_direct
=
arg
->
uncacheable_direct
;
...
...
@@ -583,7 +583,7 @@ cluster_choose(VRT_CTX,
pr
=
cluster_task_param_r
(
ctx
,
vc
);
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
)
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
`cluster` argument.
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.
The optional `real` argument allows to specify the director which use
...
...
@@ -142,7 +142,7 @@ disables special handling of uncacheable backend requests.
$Method VOID .deny(BACKEND)
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
...
...
@@ -151,7 +151,7 @@ See :ref:`meth_ctx` for limitations.
$Method VOID .allow(BACKEND)
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
...
...
@@ -160,7 +160,7 @@ See :ref:`meth_ctx` for limitations.
$Method BOOL .is_denied(BACKEND)
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
...
...
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