Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-vslp
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-vslp
Commits
55b6e90d
Commit
55b6e90d
authored
Jul 15, 2014
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow setting bereq.backend in vcl_backend_fetch
parent
43155054
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
10 deletions
+67
-10
v01010.vtc
src/tests/v01010.vtc
+50
-0
vmod_vslp.c
src/vmod_vslp.c
+9
-3
vslp_dir.c
src/vslp_dir.c
+8
-7
No files found.
src/tests/v01010.vtc
0 → 100644
View file @
55b6e90d
varnishtest "VSLP director - same as v01000.vtc but setting backend in fetch"
server s1 {
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
import vslp from "${vmod_topbuild}/src/.libs/libvmod_vslp.so" ;
sub vcl_init {
new vd = vslp.vslp();
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.set_rampup_ratio(0);
vd.init_hashcircle(25);
}
sub vcl_backend_fetch {
set bereq.backend = vd.backend();
return(fetch);
}
} -start
client c1 {
txreq -url /eishoSu2
rxresp
expect resp.body == "ech3Ooj"
txreq -url /Zainao9d
rxresp
expect resp.body == "ieQu2qua"
txreq -url /Aunah3uo
rxresp
expect resp.body == "xiuFi3Pe"
} -run
src/vmod_vslp.c
View file @
55b6e90d
...
...
@@ -125,14 +125,20 @@ vmod_vslp_backend(const struct vrt_ctx *ctx, struct vmod_vslp_vslp *vslpd)
{
uint32_t
hash
;
VCL_BACKEND
be
;
struct
http
*
http
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vslpd
,
VMOD_VSLP_VSLP_MAGIC
);
AN
(
ctx
->
http_req
);
AN
(
ctx
->
http_req
->
hd
);
/* client or backend context ? */
if
(
ctx
->
http_req
)
{
AN
(
http
=
ctx
->
http_req
);
}
else
{
AN
(
ctx
->
http_bereq
);
AN
(
http
=
ctx
->
http_bereq
);
}
hash
=
vslpd
->
vslpd
->
hash_fp
(
ctx
->
http_req
->
hd
[
HTTP_HDR_URL
].
b
);
hash
=
vslpd
->
vslpd
->
hash_fp
(
http
->
hd
[
HTTP_HDR_URL
].
b
);
be
=
vslpdir_pick_be
(
vslpd
->
vslpd
,
ctx
,
hash
);
return
(
be
);
...
...
src/vslp_dir.c
View file @
55b6e90d
...
...
@@ -393,18 +393,19 @@ vslpdir_any_healthy(struct vslpdir *vslpd)
VCL_BACKEND
vslpdir_pick_be
(
struct
vslpdir
*
vslpd
,
const
struct
vrt_ctx
*
ctx
,
uint32_t
hash
)
{
VCL_BACKEND
be
;
int
chosen
,
be_choice
,
restarts
,
n_retry
=
0
;
int
chosen
,
be_choice
,
restarts
_o
,
restarts
,
n_retry
=
0
;
struct
vslp_state
state
;
CHECK_OBJ_NOTNULL
(
vslpd
,
VSLPDIR_MAGIC
);
AN
(
ctx
->
req
);
be_choice
=
(
scalbn
(
random
(),
-
31
)
>
vslpd
->
altsrv_p
);
if
(
ctx
->
bo
)
restarts
=
ctx
->
bo
->
retries
;
else
restarts
=
ctx
->
req
->
restarts
;
if
(
ctx
->
bo
)
{
restarts
=
restarts_o
=
ctx
->
bo
->
retries
;
}
else
{
AN
(
ctx
->
req
);
restarts
=
restarts_o
=
ctx
->
req
->
restarts
;
}
state
.
picklist
=
0
;
state
.
vslpd
=
vslpd
;
...
...
@@ -428,7 +429,7 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
if
(
restarts
<=
0
)
{
char
msg
[
56
];
sprintf
(
msg
,
"VSLP picked backend %2i for key %8x in restarts: %2i"
,
chosen
,
hash
,
ctx
->
req
->
restarts
);
sprintf
(
msg
,
"VSLP picked backend %2i for key %8x in restarts: %2i"
,
chosen
,
hash
,
restarts_o
);
vlog_debug
(
ctx
,
msg
);
be
=
vslpd
->
backend
[
chosen
];
AN
(
be
);
...
...
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