Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-weightadjust
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-weightadjust
Commits
e41f4705
Commit
e41f4705
authored
Oct 05, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.1 backport
parent
cf0a7cc3
Pipeline
#308
skipped
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
29 deletions
+35
-29
configure.ac
configure.ac
+1
-1
random.c
src/random.c
+2
-2
d00004.vtc
src/tests/d00004.vtc
+23
-18
vdir.c
src/vdir.c
+6
-2
vmod_weightadjust.c
src/vmod_weightadjust.c
+1
-2
vmod_weightadjust.vcc
src/vmod_weightadjust.vcc
+0
-1
wadj_thread.c
src/wadj_thread.c
+2
-3
No files found.
configure.ac
View file @
e41f4705
...
@@ -28,7 +28,7 @@ AC_ARG_WITH([rst2man],
...
@@ -28,7 +28,7 @@ AC_ARG_WITH([rst2man],
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([5.2])
VARNISH_PREREQ([
4.1],[
5.2])
VARNISH_VMODS([weightadjust])
VARNISH_VMODS([weightadjust])
VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
...
...
src/random.c
View file @
e41f4705
...
@@ -29,12 +29,12 @@
...
@@ -29,12 +29,12 @@
#include "config.h"
#include "config.h"
#include <stdlib.h>
#include <stdlib.h>
#include <math.h>
#include "cache/cache.h"
#include "cache/cache.h"
#include "cache/cache_director.h"
#include "cache/cache_director.h"
#include "vbm.h"
#include "vbm.h"
#include "vrnd.h"
#include "vrt.h"
#include "vrt.h"
#include "vdir.h"
#include "vdir.h"
...
@@ -69,7 +69,7 @@ vmod_random_resolve(const struct director *dir, struct worker *wrk,
...
@@ -69,7 +69,7 @@ vmod_random_resolve(const struct director *dir, struct worker *wrk,
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CAST_OBJ_NOTNULL
(
rr
,
dir
->
priv
,
VMOD_DIRECTORS_RANDOM_MAGIC
);
CAST_OBJ_NOTNULL
(
rr
,
dir
->
priv
,
VMOD_DIRECTORS_RANDOM_MAGIC
);
r
=
scalbn
(
VRND_RandomTestable
(),
-
31
);
r
=
scalbn
(
random
(),
-
31
);
assert
(
r
>=
0
&&
r
<
1
.
0
);
assert
(
r
>=
0
&&
r
<
1
.
0
);
be
=
vdir_pick_be
(
rr
->
vd
,
r
,
bo
);
be
=
vdir_pick_be
(
rr
->
vd
,
r
,
bo
);
return
(
be
);
return
(
be
);
...
...
src/tests/d00004.vtc
View file @
e41f4705
varnishtest "Deeper test of random director"
varnishtest "Deeper test of random director"
random
server s1 {
server s1 {
rxreq
rxreq
txresp -body "1"
txresp -body "1"
rxreq
txresp -body "1"
} -start
} -start
server s2 {
server s2 {
...
@@ -12,17 +12,15 @@ server s2 {
...
@@ -12,17 +12,15 @@ server s2 {
txresp -body "22"
txresp -body "22"
rxreq
rxreq
txresp -body "22"
txresp -body "22"
rxreq
txresp -body "22"
rxreq
txresp -body "22"
} -start
} -start
server s3 {
server s3 {
rxreq
rxreq
txresp -body "333"
txresp -body "333"
rxreq
txresp -body "333"
rxreq
txresp -body "333"
rxreq
txresp -body "333"
} -start
} -start
server s4 {
server s4 {
...
@@ -30,13 +28,17 @@ server s4 {
...
@@ -30,13 +28,17 @@ server s4 {
txresp -body "4444"
txresp -body "4444"
rxreq
rxreq
txresp -body "4444"
txresp -body "4444"
rxreq
txresp -body "4444"
rxreq
txresp -body "4444"
} -start
} -start
varnish v1 -vcl+backend {
varnish v1 -vcl+backend {
import ${vmod_
weightadjust
};
import ${vmod_
directors
};
sub vcl_init {
sub vcl_init {
new foo =
weightadjust
.random();
new foo =
directors
.random();
foo.add_backend(s1, 1);
foo.add_backend(s1, 1);
foo.add_backend(s2, 1);
foo.add_backend(s2, 1);
foo.add_backend(s3, 1);
foo.add_backend(s3, 1);
...
@@ -52,37 +54,40 @@ varnish v1 -vcl+backend {
...
@@ -52,37 +54,40 @@ varnish v1 -vcl+backend {
}
}
} -start
} -start
varnish v1 -cliok "debug.srandom"
# NB: Do not change the number 1
# NB: Only srandom(1) is standardized as deterministic.
varnish v1 -cliok "debug.srandom 1"
client c1 {
client c1 {
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
3
expect resp.bodylen ==
2
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 4
expect resp.bodylen == 4
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
1
expect resp.bodylen ==
4
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
1
expect resp.bodylen ==
4
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
2
expect resp.bodylen ==
1
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 2
expect resp.bodylen == 2
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
3
expect resp.bodylen ==
4
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
4
expect resp.bodylen ==
2
txreq
txreq
rxresp
rxresp
expect resp.bodylen == 3
expect resp.bodylen == 3
txreq
txreq
rxresp
rxresp
expect resp.bodylen ==
3
expect resp.bodylen ==
2
} -run
} -run
src/vdir.c
View file @
e41f4705
...
@@ -72,7 +72,7 @@ vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
...
@@ -72,7 +72,7 @@ vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
vd
->
dir
->
priv
=
priv
;
vd
->
dir
->
priv
=
priv
;
vd
->
dir
->
healthy
=
healthy
;
vd
->
dir
->
healthy
=
healthy
;
vd
->
dir
->
resolve
=
resolve
;
vd
->
dir
->
resolve
=
resolve
;
vd
->
vbm
=
vbit_
new
(
8
);
vd
->
vbm
=
vbit_
init
(
8
);
AN
(
vd
->
vbm
);
AN
(
vd
->
vbm
);
}
}
...
@@ -81,7 +81,11 @@ vdir_delete(struct vdir **vdp)
...
@@ -81,7 +81,11 @@ vdir_delete(struct vdir **vdp)
{
{
struct
vdir
*
vd
;
struct
vdir
*
vd
;
TAKE_OBJ_NOTNULL
(
vd
,
vdp
,
VDIR_MAGIC
);
AN
(
vdp
);
vd
=
*
vdp
;
*
vdp
=
NULL
;
CHECK_OBJ_NOTNULL
(
vd
,
VDIR_MAGIC
);
free
(
vd
->
backend
);
free
(
vd
->
backend
);
free
(
vd
->
weight
);
free
(
vd
->
weight
);
...
...
src/vmod_weightadjust.c
View file @
e41f4705
...
@@ -50,15 +50,14 @@
...
@@ -50,15 +50,14 @@
#include "cache/cache.h"
#include "cache/cache.h"
#include "vrt.h"
#include "vcl.h"
#include "vcl.h"
#include "vrt.h"
#include "vre.h"
#include "vre.h"
#include "vsa.h"
#include "vsa.h"
#include "vtim.h"
#include "vtim.h"
#include "vtcp.h"
#include "vtcp.h"
#include "vsb.h"
#include "vsb.h"
#include "waiter/waiter.h"
#include "cache/cache_director.h"
#include "cache/cache_director.h"
#include "cache/cache_backend.h"
#include "cache/cache_backend.h"
...
...
src/vmod_weightadjust.vcc
View file @
e41f4705
...
@@ -10,7 +10,6 @@ DESCRIPTION
...
@@ -10,7 +10,6 @@ DESCRIPTION
===========
===========
$Event event_function
$Event event_function
$Object random(PRIV_VCL)
$Object random(PRIV_VCL)
Description
Description
...
...
src/wadj_thread.c
View file @
e41f4705
...
@@ -41,14 +41,13 @@
...
@@ -41,14 +41,13 @@
#include "cache/cache.h"
#include "cache/cache.h"
#include "vcl.h"
#include "vrt.h"
#include "vrt.h"
#include "vre.h"
#include "vre.h"
#include "vsa.h"
#include "vsa.h"
#include "vtim.h"
#include "vtim.h"
#include "vtcp.h"
#include "vtcp.h"
#include "vrnd.h"
#include "waiter/waiter.h"
#include "cache/cache_director.h"
#include "cache/cache_director.h"
#include "cache/cache_backend.h"
#include "cache/cache_backend.h"
...
@@ -184,7 +183,7 @@ wadj_update(void *arg)
...
@@ -184,7 +183,7 @@ wadj_update(void *arg)
POKE_TRACE
(
pr
,
"starting"
);
POKE_TRACE
(
pr
,
"starting"
);
due
.
tv_sec
=
(
long
)
VTIM_real
();
due
.
tv_sec
=
(
long
)
VTIM_real
();
due
.
tv_nsec
=
1e9
*
VRND_RandomTestableDouble
()
;
due
.
tv_nsec
=
1e9
*
(
double
)
random
()
/
(
double
)
RAND_MAX
;
AZ
(
pthread_mutex_lock
(
&
wa
->
mtx
));
AZ
(
pthread_mutex_lock
(
&
wa
->
mtx
));
while
(
pr
->
run
>=
STARTING
)
{
while
(
pr
->
run
>=
STARTING
)
{
...
...
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