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
138f97b4
Commit
138f97b4
authored
Mar 26, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic adjustment to 6.0
parent
20dcb881
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
36 deletions
+35
-36
README.rst
README.rst
+2
-0
configure.ac
configure.ac
+1
-1
random.c
src/random.c
+7
-8
wadj_basic.vtc
src/tests/wadj_basic.vtc
+9
-9
vdir.c
src/vdir.c
+0
-1
vmod_weightadjust.c
src/vmod_weightadjust.c
+7
-8
vmod_weightadjust.vcc
src/vmod_weightadjust.vcc
+1
-1
wadj_thread.c
src/wadj_thread.c
+8
-8
No files found.
README.rst
View file @
138f97b4
...
...
@@ -2,6 +2,8 @@
vmod-weightadjust
============
This version is for varnish 6.0
SYNOPSIS
========
...
...
configure.ac
View file @
138f97b4
...
...
@@ -28,7 +28,7 @@ AC_ARG_WITH([rst2man],
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([
master
])
VARNISH_PREREQ([
6.0
])
VARNISH_VMODS([weightadjust])
VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
...
...
src/random.c
View file @
138f97b4
...
...
@@ -35,7 +35,6 @@
#include "vbm.h"
#include "vrnd.h"
#include "vrt.h"
#include "vdir.h"
...
...
@@ -47,7 +46,7 @@
#define vmod_random__init _vmod_random__init
#define vmod_random__fini _vmod_random__fini
static
unsigned
__match_proto__
(
vdi_healthy
)
static
unsigned
vmod_random_healthy
(
const
struct
director
*
dir
,
const
struct
busyobj
*
bo
,
double
*
changed
)
{
...
...
@@ -57,7 +56,7 @@ vmod_random_healthy(const struct director *dir, const struct busyobj *bo,
return
(
vdir_any_healthy
(
rr
->
vd
,
bo
,
changed
));
}
static
const
struct
director
*
__match_proto__
(
vdi_resolve_f
)
static
const
struct
director
*
vmod_random_resolve
(
const
struct
director
*
dir
,
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
{
...
...
@@ -75,7 +74,7 @@ vmod_random_resolve(const struct director *dir, struct worker *wrk,
return
(
be
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random__init
(
VRT_CTX
,
struct
vmod_directors_random
**
rrp
,
const
char
*
vcl_name
)
{
...
...
@@ -91,7 +90,7 @@ vmod_random__init(VRT_CTX, struct vmod_directors_random **rrp,
vmod_random_resolve
,
rr
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random__fini
(
struct
vmod_directors_random
**
rrp
)
{
struct
vmod_directors_random
*
rr
;
...
...
@@ -104,7 +103,7 @@ vmod_random__fini(struct vmod_directors_random **rrp)
}
#ifdef UNUSED
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random_add_backend
(
VRT_CTX
,
struct
vmod_directors_random
*
rr
,
VCL_BACKEND
be
,
double
w
)
{
...
...
@@ -115,7 +114,7 @@ vmod_random_add_backend(VRT_CTX,
}
VCL_VOID
vmod_random_remove_backend
(
VRT_CTX
,
struct
vmod_directors_random
*
rr
,
VCL_BACKEND
be
)
__match_proto__
()
struct
vmod_directors_random
*
rr
,
VCL_BACKEND
be
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
rr
,
VMOD_DIRECTORS_RANDOM_MAGIC
);
...
...
@@ -123,7 +122,7 @@ VCL_VOID vmod_random_remove_backend(VRT_CTX,
}
#endif
VCL_BACKEND
__match_proto__
()
VCL_BACKEND
vmod_random_backend
(
VRT_CTX
,
struct
vmod_directors_random
*
rr
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
...
...
src/tests/wadj_basic.vtc
View file @
138f97b4
...
...
@@ -80,15 +80,15 @@ Host: weighthost
} -start
logexpect l1 -v v1 -g raw -d 1 {
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s1 starting}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s1 set to 11.345000 total 11.345000}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s1_hosthdr starting}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s1_hosthdr set to 12.345000 total 23.690000}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s1 stopping}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s2 starting}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s2 set to 3.789000 total 16.134000}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s3 starting}
expect * * Debug {^vmod weightadjust: poke foo.
vcl1.
s3 set to 42.000000 total 58.134000}
expect * * Debug {^vmod weightadjust: poke foo.s1 starting}
expect * * Debug {^vmod weightadjust: poke foo.s1 set to 11.345000 total 11.345000}
expect * * Debug {^vmod weightadjust: poke foo.s1_hosthdr starting}
expect * * Debug {^vmod weightadjust: poke foo.s1_hosthdr set to 12.345000 total 23.690000}
expect * * Debug {^vmod weightadjust: poke foo.s1 stopping}
expect * * Debug {^vmod weightadjust: poke foo.s2 starting}
expect * * Debug {^vmod weightadjust: poke foo.s2 set to 3.789000 total 16.134000}
expect * * Debug {^vmod weightadjust: poke foo.s3 starting}
expect * * Debug {^vmod weightadjust: poke foo.s3 set to 42.000000 total 58.134000}
} -start
client c1 {
...
...
src/vdir.c
View file @
138f97b4
...
...
@@ -33,7 +33,6 @@
#include "cache/cache.h"
#include "cache/cache_director.h"
#include "vrt.h"
#include "vbm.h"
#include "vdir.h"
...
...
src/vmod_weightadjust.c
View file @
138f97b4
...
...
@@ -46,7 +46,6 @@
#include "cache/cache.h"
#include "vrt.h"
#include "vcl.h"
#include "vre.h"
#include "vsa.h"
...
...
@@ -95,7 +94,7 @@ msg(VRT_CTX, int fail, const char *fmt, ...)
va_end
(
args
);
}
static
void
__match_proto__
(
vmod_priv_free_f
)
static
void
priv_vcl_free
(
void
*
priv
)
{
struct
vmod_wadj_vcl
*
wa_vcl
;
...
...
@@ -108,7 +107,7 @@ priv_vcl_free(void *priv)
AZ
(
wa_vcl
);
}
int
__match_proto__
(
vmod_event_f
)
int
event_function
(
VRT_CTX
,
struct
vmod_priv
*
priv
,
enum
vcl_event_e
e
)
{
struct
vmod_wadj_vcl
*
wa_vcl
;
...
...
@@ -207,7 +206,7 @@ wadj_cfg_req(const struct backend *be, VCL_STRING url, VCL_STRING request,
return
(
ret
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random__init
(
VRT_CTX
,
struct
vmod_weightadjust_random
**
rrp
,
const
char
*
vcl_name
,
struct
vmod_priv
*
priv
)
{
...
...
@@ -224,7 +223,7 @@ vmod_random__init(VRT_CTX, struct vmod_weightadjust_random **rrp,
VTAILQ_INIT
(
&
rr
->
extra
.
props
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random__fini
(
struct
vmod_weightadjust_random
**
rrp
)
{
struct
vmod_weightadjust_random
*
rr
;
...
...
@@ -244,7 +243,7 @@ vmod_random__fini(struct vmod_weightadjust_random **rrp)
AZ
(
rr
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random_add_backend
(
VRT_CTX
,
struct
vmod_weightadjust_random
*
rr
,
VCL_BACKEND
vcl_be
,
VCL_REAL
w
,
VCL_STRING
weight_update
,
VCL_STRING
url
,
VCL_STRING
request
,
VCL_DURATION
timeout
,
VCL_DURATION
interval
,
...
...
@@ -285,7 +284,7 @@ vmod_random_add_backend(VRT_CTX, struct vmod_weightadjust_random *rr,
vdir_unlock
(
rr
->
vd
);
if
(
u
<
nb
)
{
VERR
(
ctx
,
"director %s add_backend(%s): already exists"
,
rr
->
vd
->
dir
->
vcl_name
,
be
->
display
_name
);
rr
->
vd
->
dir
->
vcl_name
,
be
->
vcl
_name
);
return
;
}
...
...
@@ -329,7 +328,7 @@ vmod_random_add_backend(VRT_CTX, struct vmod_weightadjust_random *rr,
FREE_OBJ
(
prop
);
}
VCL_VOID
__match_proto__
()
VCL_VOID
vmod_random_remove_backend
(
VRT_CTX
,
struct
vmod_weightadjust_random
*
rr
,
VCL_BACKEND
vcl_be
)
{
...
...
src/vmod_weightadjust.vcc
View file @
138f97b4
...
...
@@ -2,7 +2,7 @@
# This document is copyright and licensed under the same conditions as
# the libvmod-weightadjust project. See LICENSE for details.
$Module weightadjust 3
Weightadjust VMOD
$Module weightadjust 3
"random director with runtime adjustable weight"
DESCRIPTION
===========
...
...
src/wadj_thread.c
View file @
138f97b4
...
...
@@ -45,7 +45,6 @@
#include "cache/cache.h"
#include "vrt.h"
#include "vre.h"
#include "vsa.h"
#include "vtim.h"
...
...
@@ -58,7 +57,7 @@
#ifdef FIXME
#include "cache/cache_tcp_pool.h"
#else
int
VTP_Open
(
const
struct
tcp_pool
*
,
double
tmo
,
const
struct
suckaddr
*
*
);
int
VTP_Open
(
struct
tcp_pool
*
,
vtim_dur
tmo
,
const
void
**
,
int
*
);
#endif
#include "vdir.h"
...
...
@@ -68,24 +67,24 @@ int VTP_Open(const struct tcp_pool *, double tmo, const struct suckaddr **);
#define POKE_ERR(prop, fmt, ...) \
VSL(SLT_VCL_Error, 0, "vmod weightadjust error: poke %s.%s " fmt, \
(prop)->vd->dir->vcl_name, (prop)->be->
display
_name, \
(prop)->vd->dir->vcl_name, (prop)->be->
vcl
_name, \
__VA_ARGS__)
#define VPOKE_TRACE(prop, fmt, ...) \
VSL(SLT_Debug, 0, "vmod weightadjust: poke %s.%s " fmt, \
(prop)->vd->dir->vcl_name, (prop)->be->
display
_name, \
(prop)->vd->dir->vcl_name, (prop)->be->
vcl
_name, \
__VA_ARGS__)
#define POKE_TRACE(prop, str) \
VSL(SLT_Debug, 0, "vmod weightadjust: poke %s.%s " str, \
(prop)->vd->dir->vcl_name, (prop)->be->
display
_name)
(prop)->vd->dir->vcl_name, (prop)->be->
vcl
_name)
/* largely copied from vbp_poke */
static
void
wadj_poke
(
const
struct
wadj_prop
*
prop
,
char
*
buf
,
unsigned
*
len
)
{
int
s
,
tmo
,
i
;
int
s
,
tmo
,
i
,
err
;
double
t_start
,
t_now
,
t_end
;
unsigned
rlen
;
struct
pollfd
pfda
[
1
],
*
pfd
=
pfda
;
...
...
@@ -99,10 +98,11 @@ wadj_poke(const struct wadj_prop *prop, char *buf,
*
buf
=
'\0'
;
*
len
=
0
;
s
=
VTP_Open
(
prop
->
be
->
tcp_pool
,
t_end
-
t_now
,
&
sa
);
s
=
VTP_Open
(
prop
->
be
->
tcp_pool
,
t_end
-
t_now
,
(
const
void
**
)
&
sa
,
&
err
);
if
(
s
<
0
)
{
POKE_ERR
(
prop
,
"
no connection %s"
,
strerror
(
errno
));
POKE_ERR
(
prop
,
"
Open error %d (%s)"
,
err
,
strerror
(
err
));
return
;
}
...
...
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