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
0d68e21d
Commit
0d68e21d
authored
Nov 24, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use trivial VRT_Assign_Backend() to assign VCL_BACKEND to variables.
(First part of #3599)
parent
0c69a758
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
10 deletions
+42
-10
cache_busyobj.c
bin/varnishd/cache/cache_busyobj.c
+3
-1
cache_director.c
bin/varnishd/cache/cache_director.c
+2
-2
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+3
-1
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+11
-2
cache_vrt_vcl.c
bin/varnishd/cache/cache_vrt_vcl.c
+8
-0
vrt.h
include/vrt.h
+4
-0
vmod_directors.c
vmod/vmod_directors.c
+6
-1
vmod_directors_shard_cfg.c
vmod/vmod_directors_shard_cfg.c
+5
-3
No files found.
bin/varnishd/cache/cache_busyobj.c
View file @
0d68e21d
...
@@ -137,7 +137,7 @@ VBO_GetBusyObj(const struct worker *wrk, const struct req *req)
...
@@ -137,7 +137,7 @@ VBO_GetBusyObj(const struct worker *wrk, const struct req *req)
XXXAN
(
bo
->
client_identity
);
XXXAN
(
bo
->
client_identity
);
}
}
bo
->
director_req
=
req
->
director_hint
;
VRT_Assign_Backend
(
&
bo
->
director_req
,
req
->
director_hint
)
;
bo
->
vcl
=
req
->
vcl
;
bo
->
vcl
=
req
->
vcl
;
VCL_Ref
(
bo
->
vcl
);
VCL_Ref
(
bo
->
vcl
);
...
@@ -180,6 +180,8 @@ VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **pbo)
...
@@ -180,6 +180,8 @@ VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **pbo)
HSH_RUSH_POLICY
);
HSH_RUSH_POLICY
);
}
}
VRT_Assign_Backend
(
&
bo
->
director_req
,
NULL
);
VRT_Assign_Backend
(
&
bo
->
director_resp
,
NULL
);
VCL_Rel
(
&
bo
->
vcl
);
VCL_Rel
(
&
bo
->
vcl
);
#ifdef ENABLE_WORKSPACE_EMULATOR
#ifdef ENABLE_WORKSPACE_EMULATOR
WS_Rollback
(
bo
->
ws
,
0
);
WS_Rollback
(
bo
->
ws
,
0
);
...
...
bin/varnishd/cache/cache_director.c
View file @
0d68e21d
...
@@ -140,7 +140,7 @@ VDI_GetHdr(struct busyobj *bo)
...
@@ -140,7 +140,7 @@ VDI_GetHdr(struct busyobj *bo)
d
=
VDI_Resolve
(
ctx
);
d
=
VDI_Resolve
(
ctx
);
if
(
d
!=
NULL
)
{
if
(
d
!=
NULL
)
{
bo
->
director_resp
=
d
;
VRT_Assign_Backend
(
&
bo
->
director_resp
,
d
)
;
AN
(
d
->
vdir
->
methods
->
gethdrs
);
AN
(
d
->
vdir
->
methods
->
gethdrs
);
bo
->
director_state
=
DIR_S_HDRS
;
bo
->
director_state
=
DIR_S_HDRS
;
i
=
d
->
vdir
->
methods
->
gethdrs
(
ctx
,
d
);
i
=
d
->
vdir
->
methods
->
gethdrs
(
ctx
,
d
);
...
@@ -214,7 +214,7 @@ VDI_Http1Pipe(struct req *req, struct busyobj *bo)
...
@@ -214,7 +214,7 @@ VDI_Http1Pipe(struct req *req, struct busyobj *bo)
VSLb
(
bo
->
vsl
,
SLT_VCL_Error
,
"Backend does not support pipe"
);
VSLb
(
bo
->
vsl
,
SLT_VCL_Error
,
"Backend does not support pipe"
);
return
(
SC_TX_ERROR
);
return
(
SC_TX_ERROR
);
}
}
bo
->
director_resp
=
d
;
VRT_Assign_Backend
(
&
bo
->
director_resp
,
d
)
;
return
(
d
->
vdir
->
methods
->
http1pipe
(
ctx
,
d
));
return
(
d
->
vdir
->
methods
->
http1pipe
(
ctx
,
d
));
}
}
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
0d68e21d
...
@@ -876,7 +876,8 @@ cnt_recv_prep(struct req *req, const char *ci)
...
@@ -876,7 +876,8 @@ cnt_recv_prep(struct req *req, const char *ci)
http_CollectHdr
(
req
->
http
,
H_Cache_Control
);
http_CollectHdr
(
req
->
http
,
H_Cache_Control
);
/* By default we use the first backend */
/* By default we use the first backend */
req
->
director_hint
=
VCL_DefaultDirector
(
req
->
vcl
);
VRT_Assign_Backend
(
&
req
->
director_hint
,
VCL_DefaultDirector
(
req
->
vcl
));
req
->
d_ttl
=
-
1
;
req
->
d_ttl
=
-
1
;
req
->
d_grace
=
-
1
;
req
->
d_grace
=
-
1
;
...
@@ -1190,6 +1191,7 @@ CNT_Request(struct req *req)
...
@@ -1190,6 +1191,7 @@ CNT_Request(struct req *req)
VCL_TaskLeave
(
ctx
,
req
->
privs
);
VCL_TaskLeave
(
ctx
,
req
->
privs
);
AN
(
req
->
vsl
->
wid
);
AN
(
req
->
vsl
->
wid
);
VRB_Free
(
req
);
VRB_Free
(
req
);
VRT_Assign_Backend
(
&
req
->
director_hint
,
NULL
);
req
->
wrk
=
NULL
;
req
->
wrk
=
NULL
;
}
}
assert
(
nxt
==
REQ_FSM_DISEMBARK
||
!
WS_IsReserved
(
req
->
ws
));
assert
(
nxt
==
REQ_FSM_DISEMBARK
||
!
WS_IsReserved
(
req
->
ws
));
...
...
bin/varnishd/cache/cache_vrt_var.c
View file @
0d68e21d
...
@@ -504,13 +504,22 @@ VRT_r_req_##nm(VRT_CTX) \
...
@@ -504,13 +504,22 @@ VRT_r_req_##nm(VRT_CTX) \
return (ctx->req->elem); \
return (ctx->req->elem); \
}
}
REQ_VAR_L
(
backend_hint
,
director_hint
,
VCL_BACKEND
,)
REQ_VAR_R
(
backend_hint
,
director_hint
,
VCL_BACKEND
)
REQ_VAR_R
(
backend_hint
,
director_hint
,
VCL_BACKEND
)
REQ_VAR_L
(
ttl
,
d_ttl
,
VCL_DURATION
,
if
(
!
(
arg
>
0
.
0
))
arg
=
0
;)
REQ_VAR_L
(
ttl
,
d_ttl
,
VCL_DURATION
,
if
(
!
(
arg
>
0
.
0
))
arg
=
0
;)
REQ_VAR_R
(
ttl
,
d_ttl
,
VCL_DURATION
)
REQ_VAR_R
(
ttl
,
d_ttl
,
VCL_DURATION
)
REQ_VAR_L
(
grace
,
d_grace
,
VCL_DURATION
,
if
(
!
(
arg
>
0
.
0
))
arg
=
0
;)
REQ_VAR_L
(
grace
,
d_grace
,
VCL_DURATION
,
if
(
!
(
arg
>
0
.
0
))
arg
=
0
;)
REQ_VAR_R
(
grace
,
d_grace
,
VCL_DURATION
)
REQ_VAR_R
(
grace
,
d_grace
,
VCL_DURATION
)
VCL_VOID
VRT_l_req_backend_hint
(
VRT_CTX
,
VCL_BACKEND
be
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
VRT_Assign_Backend
(
&
ctx
->
req
->
director_hint
,
be
);
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
VCL_VOID
VCL_VOID
...
@@ -519,7 +528,7 @@ VRT_l_bereq_backend(VRT_CTX, VCL_BACKEND be)
...
@@ -519,7 +528,7 @@ VRT_l_bereq_backend(VRT_CTX, VCL_BACKEND be)
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
ctx
->
bo
->
director_req
=
be
;
VRT_Assign_Backend
(
&
ctx
->
bo
->
director_req
,
be
)
;
}
}
VCL_BACKEND
VCL_BACKEND
...
...
bin/varnishd/cache/cache_vrt_vcl.c
View file @
0d68e21d
...
@@ -251,6 +251,14 @@ VRT_DelDirector(VCL_BACKEND *bp)
...
@@ -251,6 +251,14 @@ VRT_DelDirector(VCL_BACKEND *bp)
vcldir_free
(
vdir
);
vcldir_free
(
vdir
);
}
}
void
VRT_Assign_Backend
(
VCL_BACKEND
*
dst
,
VCL_BACKEND
src
)
{
AN
(
dst
);
*
dst
=
src
;
}
void
void
VRT_DisableDirector
(
VCL_BACKEND
d
)
VRT_DisableDirector
(
VCL_BACKEND
d
)
{
{
...
...
include/vrt.h
View file @
0d68e21d
...
@@ -53,6 +53,9 @@
...
@@ -53,6 +53,9 @@
* Whenever something is deleted or changed in a way which is not
* Whenever something is deleted or changed in a way which is not
* binary/load-time compatible, increment MAJOR version
* binary/load-time compatible, increment MAJOR version
*
*
* Next (2021-03-15)
* VRT_Assign_Backend added
*
* 14.0 (2021-09-15)
* 14.0 (2021-09-15)
* VIN_n_Arg() no directly returns the directory name.
* VIN_n_Arg() no directly returns the directory name.
* VSB_new() and VSB_delete() removed
* VSB_new() and VSB_delete() removed
...
@@ -682,6 +685,7 @@ VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct vdi_methods *,
...
@@ -682,6 +685,7 @@ VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct vdi_methods *,
void
VRT_DisableDirector
(
VCL_BACKEND
);
void
VRT_DisableDirector
(
VCL_BACKEND
);
VCL_BACKEND
VRT_LookupDirector
(
VRT_CTX
,
VCL_STRING
);
VCL_BACKEND
VRT_LookupDirector
(
VRT_CTX
,
VCL_STRING
);
void
VRT_DelDirector
(
VCL_BACKEND
*
);
void
VRT_DelDirector
(
VCL_BACKEND
*
);
void
VRT_Assign_Backend
(
VCL_BACKEND
*
dst
,
VCL_BACKEND
src
);
/***********************************************************************
/***********************************************************************
* vmod_priv related
* vmod_priv related
...
...
vmod/vmod_directors.c
View file @
0d68e21d
...
@@ -96,10 +96,13 @@ void
...
@@ -96,10 +96,13 @@ void
vdir_delete
(
struct
vdir
**
vdp
)
vdir_delete
(
struct
vdir
**
vdp
)
{
{
struct
vdir
*
vd
;
struct
vdir
*
vd
;
unsigned
u
;
TAKE_OBJ_NOTNULL
(
vd
,
vdp
,
VDIR_MAGIC
);
TAKE_OBJ_NOTNULL
(
vd
,
vdp
,
VDIR_MAGIC
);
AZ
(
vd
->
dir
);
AZ
(
vd
->
dir
);
for
(
u
=
0
;
u
<
vd
->
n_backend
;
u
++
)
VRT_Assign_Backend
(
&
vd
->
backend
[
u
],
NULL
);
free
(
vd
->
backend
);
free
(
vd
->
backend
);
free
(
vd
->
weight
);
free
(
vd
->
weight
);
AZ
(
pthread_rwlock_destroy
(
&
vd
->
mtx
));
AZ
(
pthread_rwlock_destroy
(
&
vd
->
mtx
));
...
@@ -147,7 +150,8 @@ vdir_add_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, double weight)
...
@@ -147,7 +150,8 @@ vdir_add_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, double weight)
vdir_expand
(
vd
,
vd
->
l_backend
+
16
);
vdir_expand
(
vd
,
vd
->
l_backend
+
16
);
assert
(
vd
->
n_backend
<
vd
->
l_backend
);
assert
(
vd
->
n_backend
<
vd
->
l_backend
);
u
=
vd
->
n_backend
++
;
u
=
vd
->
n_backend
++
;
vd
->
backend
[
u
]
=
be
;
vd
->
backend
[
u
]
=
NULL
;
VRT_Assign_Backend
(
&
vd
->
backend
[
u
],
be
);
vd
->
weight
[
u
]
=
weight
;
vd
->
weight
[
u
]
=
weight
;
vdir_unlock
(
vd
);
vdir_unlock
(
vd
);
}
}
...
@@ -173,6 +177,7 @@ vdir_remove_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, unsigned *cur)
...
@@ -173,6 +177,7 @@ vdir_remove_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, unsigned *cur)
vdir_unlock
(
vd
);
vdir_unlock
(
vd
);
return
;
return
;
}
}
VRT_Assign_Backend
(
&
vd
->
backend
[
u
],
NULL
);
n
=
(
vd
->
n_backend
-
u
)
-
1
;
n
=
(
vd
->
n_backend
-
u
)
-
1
;
memmove
(
&
vd
->
backend
[
u
],
&
vd
->
backend
[
u
+
1
],
n
*
sizeof
(
vd
->
backend
[
0
]));
memmove
(
&
vd
->
backend
[
u
],
&
vd
->
backend
[
u
+
1
],
n
*
sizeof
(
vd
->
backend
[
0
]));
memmove
(
&
vd
->
weight
[
u
],
&
vd
->
weight
[
u
+
1
],
n
*
sizeof
(
vd
->
weight
[
0
]));
memmove
(
&
vd
->
weight
[
u
],
&
vd
->
weight
[
u
+
1
],
n
*
sizeof
(
vd
->
weight
[
0
]));
...
...
vmod/vmod_directors_shard_cfg.c
View file @
0d68e21d
...
@@ -195,7 +195,8 @@ shard_change_task_backend(VRT_CTX, struct sharddir *shardd,
...
@@ -195,7 +195,8 @@ shard_change_task_backend(VRT_CTX, struct sharddir *shardd,
return
(
NULL
);
return
(
NULL
);
}
}
b
->
backend
=
be
;
b
->
backend
=
NULL
;
VRT_Assign_Backend
(
&
b
->
backend
,
be
);
b
->
ident
=
ident
!=
NULL
&&
*
ident
!=
'\0'
?
ident
:
NULL
;
b
->
ident
=
ident
!=
NULL
&&
*
ident
!=
'\0'
?
ident
:
NULL
;
b
->
rampup
=
rampup
;
b
->
rampup
=
rampup
;
...
@@ -333,6 +334,7 @@ shardcfg_backend_free(struct shard_backend *f)
...
@@ -333,6 +334,7 @@ shardcfg_backend_free(struct shard_backend *f)
{
{
if
(
f
->
freeptr
)
if
(
f
->
freeptr
)
free
(
f
->
freeptr
);
free
(
f
->
freeptr
);
VRT_Assign_Backend
(
&
f
->
backend
,
NULL
);
memset
(
f
,
0
,
sizeof
(
*
f
));
memset
(
f
,
0
,
sizeof
(
*
f
));
}
}
...
@@ -466,8 +468,7 @@ shardcfg_backend_clear(struct sharddir *shardd)
...
@@ -466,8 +468,7 @@ shardcfg_backend_clear(struct sharddir *shardd)
static
void
static
void
shardcfg_backend_del
(
struct
backend_reconfig
*
re
,
shardcfg_backend_del
(
struct
backend_reconfig
*
re
,
struct
shard_backend
*
spec
)
const
struct
shard_backend
*
spec
)
{
{
unsigned
i
,
max
=
re
->
shardd
->
n_backend
+
re
->
hole_n
;
unsigned
i
,
max
=
re
->
shardd
->
n_backend
+
re
->
hole_n
;
struct
shard_backend
*
const
bb
=
re
->
shardd
->
backend
;
struct
shard_backend
*
const
bb
=
re
->
shardd
->
backend
;
...
@@ -485,6 +486,7 @@ shardcfg_backend_del(struct backend_reconfig *re,
...
@@ -485,6 +486,7 @@ shardcfg_backend_del(struct backend_reconfig *re,
re
->
hole_i
=
vmin
(
re
->
hole_i
,
i
);
re
->
hole_i
=
vmin
(
re
->
hole_i
,
i
);
}
}
}
}
VRT_Assign_Backend
(
&
spec
->
backend
,
NULL
);
}
}
static
void
static
void
...
...
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