Commit 138f97b4 authored by Nils Goroll's avatar Nils Goroll

basic adjustment to 6.0

parent 20dcb881
......@@ -2,6 +2,8 @@
vmod-weightadjust
============
This version is for varnish 6.0
SYNOPSIS
========
......
......@@ -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)"
......
......@@ -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);
......
......@@ -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 {
......
......@@ -33,7 +33,6 @@
#include "cache/cache.h"
#include "cache/cache_director.h"
#include "vrt.h"
#include "vbm.h"
#include "vdir.h"
......
......@@ -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)
{
......
......@@ -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
===========
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment