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
d00de5d7
Commit
d00de5d7
authored
Aug 07, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also eliminat C-enum detour for 'healthy' arguments
parent
56d9cf80
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
41 deletions
+13
-41
Makefile.am
lib/libvmod_directors/Makefile.am
+1
-2
shard_dir.c
lib/libvmod_directors/shard_dir.c
+7
-5
shard_dir.h
lib/libvmod_directors/shard_dir.h
+1
-8
tbl_healthy.h
lib/libvmod_directors/tbl_healthy.h
+0
-4
vmod_shard.c
lib/libvmod_directors/vmod_shard.c
+4
-22
No files found.
lib/libvmod_directors/Makefile.am
View file @
d00de5d7
...
...
@@ -12,8 +12,7 @@ libvmod_directors_la_SOURCES = \
shard_cfg.c
\
shard_cfg.h
\
shard_dir.c
\
shard_dir.h
\
tbl_healthy.h
shard_dir.h
# Use vmodtool.py generated automake boilerplate
include
$(srcdir)/automake_boilerplate.am
lib/libvmod_directors/shard_dir.c
View file @
d00de5d7
...
...
@@ -43,6 +43,7 @@
#include "vsha256.h"
#include "vend.h"
#include "vcc_if.h"
#include "shard_dir.h"
struct
shard_be_info
{
...
...
@@ -323,7 +324,7 @@ sharddir_any_healthy(VRT_CTX, struct sharddir *shardd, VCL_TIME *changed)
static
VCL_BACKEND
sharddir_pick_be_locked
(
VRT_CTX
,
const
struct
sharddir
*
shardd
,
uint32_t
key
,
VCL_INT
alt
,
VCL_REAL
warmup
,
VCL_BOOL
rampup
,
enum
healthy_e
healthy
,
VCL_INT
alt
,
VCL_REAL
warmup
,
VCL_BOOL
rampup
,
VCL_ENUM
healthy
,
struct
shard_state
*
state
)
{
VCL_BACKEND
be
;
...
...
@@ -345,7 +346,8 @@ sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key,
key
,
state
->
idx
,
shardd
->
hashcircle
[
state
->
idx
].
host
);
if
(
alt
>
0
)
{
if
(
shard_next
(
state
,
alt
-
1
,
healthy
==
ALL
?
1
:
0
)
==
-
1
)
{
if
(
shard_next
(
state
,
alt
-
1
,
healthy
==
VENUM
(
ALL
)
?
1
:
0
)
==
-
1
)
{
if
(
state
->
previous
.
hostid
!=
-
1
)
{
be
=
sharddir_backend
(
shardd
,
state
->
previous
.
hostid
);
...
...
@@ -356,7 +358,7 @@ sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key,
}
}
if
(
shard_next
(
state
,
0
,
healthy
==
IGNORE
?
0
:
1
)
==
-
1
)
{
if
(
shard_next
(
state
,
0
,
healthy
==
VENUM
(
IGNORE
)
?
0
:
1
)
==
-
1
)
{
if
(
state
->
previous
.
hostid
!=
-
1
)
{
be
=
sharddir_backend
(
shardd
,
state
->
previous
.
hostid
);
AN
(
be
);
...
...
@@ -372,7 +374,7 @@ sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key,
warmup
=
shardd
->
warmup
;
/* short path for cases we dont want ramup/warmup or can't */
if
(
alt
>
0
||
healthy
==
IGNORE
||
(
!
rampup
&&
warmup
==
0
)
||
if
(
alt
>
0
||
healthy
==
VENUM
(
IGNORE
)
||
(
!
rampup
&&
warmup
==
0
)
||
shard_next
(
state
,
0
,
1
)
==
-
1
)
return
(
be
);
...
...
@@ -415,7 +417,7 @@ sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key,
VCL_BACKEND
sharddir_pick_be
(
VRT_CTX
,
struct
sharddir
*
shardd
,
uint32_t
key
,
VCL_INT
alt
,
VCL_REAL
warmup
,
VCL_BOOL
rampup
,
enum
healthy_e
healthy
)
VCL_REAL
warmup
,
VCL_BOOL
rampup
,
VCL_ENUM
healthy
)
{
VCL_BACKEND
be
;
struct
shard_state
state
[
1
];
...
...
lib/libvmod_directors/shard_dir.h
View file @
d00de5d7
...
...
@@ -27,13 +27,6 @@
* SUCH DAMAGE.
*/
enum
healthy_e
{
_HEALTHY_E_INVALID
=
0
,
#define VMODENUM(x) x,
#include "tbl_healthy.h"
_HEALTHY_E_MAX
};
struct
vbitmap
;
struct
shard_circlepoint
{
...
...
@@ -116,7 +109,7 @@ void sharddir_wrlock(struct sharddir *shardd);
void
sharddir_unlock
(
struct
sharddir
*
shardd
);
VCL_BOOL
sharddir_any_healthy
(
VRT_CTX
,
struct
sharddir
*
,
VCL_TIME
*
);
VCL_BACKEND
sharddir_pick_be
(
VRT_CTX
,
struct
sharddir
*
,
uint32_t
,
VCL_INT
,
VCL_REAL
,
VCL_BOOL
,
enum
healthy_e
);
VCL_REAL
,
VCL_BOOL
,
VCL_ENUM
healthy
);
/* in shard_cfg.c */
void
shardcfg_delete
(
const
struct
sharddir
*
shardd
);
...
...
lib/libvmod_directors/tbl_healthy.h
deleted
100644 → 0
View file @
56d9cf80
VMODENUM
(
CHOSEN
)
VMODENUM
(
IGNORE
)
VMODENUM
(
ALL
)
#undef VMODENUM
lib/libvmod_directors/vmod_shard.c
View file @
d00de5d7
...
...
@@ -128,7 +128,7 @@ struct vmod_directors_shard_param {
/* parameters */
VCL_ENUM
by
;
enum
healthy_e
healthy
;
VCL_ENUM
healthy
;
uint32_t
mask
;
VCL_BOOL
rampup
;
VCL_INT
alt
;
...
...
@@ -144,13 +144,13 @@ static const struct vmod_directors_shard_param shard_param_default = {
.
scope
=
SCOPE_VMOD
,
.
mask
=
arg_mask_param_
,
.
healthy
=
CHOSEN
,
.
rampup
=
1
,
.
alt
=
0
,
.
warmup
=
-
1
,
};
#define default_by(ptr) (ptr == NULL ? VENUM(HASH) : ptr)
#define default_healthy(ptr) (ptr == NULL ? VENUM(CHOSEN) : ptr)
static
struct
vmod_directors_shard_param
*
shard_param_stack
(
struct
vmod_directors_shard_param
*
p
,
...
...
@@ -182,20 +182,6 @@ struct vmod_directors_shard {
VCL_BACKEND
dir
;
};
static
enum
healthy_e
parse_healthy_e
(
VCL_ENUM
e
)
{
#define VMODENUM(n) if (e == VENUM(n)) return(n);
#include "tbl_healthy.h"
WRONG
(
"illegal healthy enum"
);
}
static
const
char
*
const
healthy_str
[
_HEALTHY_E_MAX
]
=
{
[
_HEALTHY_E_INVALID
]
=
"*INVALID*"
,
#define VMODENUM(n) [n] = #n,
#include "tbl_healthy.h"
};
static
void
shard__assert
(
void
)
{
...
...
@@ -504,7 +490,6 @@ shard_param_args(VRT_CTX,
uint32_t
args
,
VCL_ENUM
by_s
,
VCL_INT
key_int
,
VCL_BLOB
key_blob
,
VCL_INT
alt
,
VCL_REAL
warmup
,
VCL_BOOL
rampup
,
VCL_ENUM
healthy_s
)
{
enum
healthy_e
healthy
;
CHECK_OBJ_NOTNULL
(
p
,
VMOD_SHARD_SHARD_PARAM_MAGIC
);
AN
(
p
->
vcl_name
);
...
...
@@ -514,7 +499,6 @@ shard_param_args(VRT_CTX,
if
(
!
(
args
&
arg_by
))
by_s
=
NULL
;
by_s
=
default_by
(
by_s
);
healthy
=
(
args
&
arg_healthy
)
?
parse_healthy_e
(
healthy_s
)
:
CHOSEN
;
/* by_s / key_int / key_blob */
if
(
by_s
==
VENUM
(
KEY
))
{
...
...
@@ -587,7 +571,7 @@ shard_param_args(VRT_CTX,
p
->
rampup
=
!!
rampup
;
if
(
args
&
arg_healthy
)
p
->
healthy
=
healthy
;
p
->
healthy
=
healthy
_s
;
p
->
mask
=
args
&
arg_mask_param_
;
return
(
p
);
...
...
@@ -1063,9 +1047,7 @@ vmod_shard_param_get_healthy(VRT_CTX,
"shard_param.get_healthy()"
);
if
(
pp
==
NULL
)
return
(
NULL
);
assert
(
pp
->
healthy
>
_HEALTHY_E_INVALID
);
return
(
healthy_str
[
pp
->
healthy
]);
return
(
default_healthy
(
pp
->
healthy
));
}
static
const
struct
vmod_directors_shard_param
*
...
...
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