aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-20 14:10:33 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-01-20 14:10:33 +0200
commit741817ac5372c374b52b710dd8a4b0cc463ade99 (patch)
tree46343899a7e7249c8306e227a59dabc4e9e04dec
parent67731a160cc7c3e090236316af459f695593fc55 (diff)
downloadvmod-tbf-741817ac5372c374b52b710dd8a4b0cc463ade99.tar.gz
vmod-tbf-741817ac5372c374b52b710dd8a4b0cc463ade99.tar.bz2
Drop support for Varnish 3
* configure.ac: Use pkg-config. Save Varnishapi version in VARNISHAPI_MAJOR, VARNISHAPI_MINOR, VARNISHAPI_PATCH Refuse to run if it is prior to 4.1 * src/Makefile.am: Remove conditionals * src/tbf.h: Remove Varnish 3.0 defines * src/vmod-tbf.3: Update * tests/Makefile.am: Remove conditionals * tests/test00.vti: Rename to tests/test00.vtc * tests/test02.vti: Rename to tests/test02.vtc
-rw-r--r--configure.ac52
-rw-r--r--src/Makefile.am17
-rw-r--r--src/tbf.h20
-rw-r--r--src/vmod-tbf.32
-rw-r--r--tests/Makefile.am21
-rw-r--r--tests/test00.vtc (renamed from tests/test00.vti)8
-rw-r--r--tests/test02.vtc (renamed from tests/test02.vti)8
7 files changed, 55 insertions, 73 deletions
diff --git a/configure.ac b/configure.ac
index f8e19de..8041a57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1# This file is part of vmod-tbf -*- autoconf -*- 1# This file is part of vmod-tbf -*- autoconf -*-
2# Copyright (C) 2013-2014 Sergey Poznyakoff 2# Copyright (C) 2013-2016 Sergey Poznyakoff
3# 3#
4# Vmod-tbf is free software; you can redistribute it and/or modify 4# Vmod-tbf is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
@@ -67,17 +67,37 @@ case "$VARNISHSRC" in
67esac 67esac
68 68
69VARNISHSRC=`cd $VARNISHSRC && pwd` 69VARNISHSRC=`cd $VARNISHSRC && pwd`
70VARNISHVERSION= 70
71AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], 71
72 [VARNISHVERSION=3], 72# pkg-config
73 [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h], 73PKG_PROG_PKG_CONFIG
74 [VARNISHVERSION=4], 74PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
75 [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ]) 75
76AC_SUBST([VARNISHVERSION],$VARNISHVERSION) 76varnishapi_version() {
77 77 VARNISHAPI_MAJOR=$1
78AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) 78 VARNISHAPI_MINOR=$2
79AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) 79 VARNISHAPI_PATCH=$3
80AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) 80}
81
82v=$($PKG_CONFIG --modversion varnishapi)
83if test -n "$v"; then
84 save_IFS=$IFS
85 IFS='.'
86 varnishapi_version $v
87 IFS=$save_IFS
88else
89 AC_MSG_ERROR([unknown varnishapi version])
90fi
91
92if test $VARNISHAPI_MAJOR -ne 4; then
93 AC_MSG_ERROR([unsupported varnishapi version])
94fi
95
96case $VARNISHAPI_MINOR in
970) AC_MSG_ERROR([unsupported varnishapi version]);;
981) ;;
99*) AC_MSG_WARN([varnishapi minor version probably unsupported])
100esac
81 101
82# Check that varnishtest is built in the varnish source directory 102# Check that varnishtest is built in the varnish source directory
83AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], 103AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
@@ -94,7 +114,7 @@ AC_ARG_WITH([vmoddir],
94 /*) VMODDIR=$withval;; 114 /*) VMODDIR=$withval;;
95 no) unset VMODDIR;; 115 no) unset VMODDIR;;
96 *) AC_MSG_ERROR([argument to --with-vmoddir must be absolute pathname]) 116 *) AC_MSG_ERROR([argument to --with-vmoddir must be absolute pathname])
97 esac],[VMODDIR=`pkg-config --variable=vmoddir varnishapi` 117 esac],[VMODDIR=$($PKG_CONFIG --variable=vmoddir varnishapi)
98 if test -z "$VMODDIR"; then 118 if test -z "$VMODDIR"; then
99 AC_MSG_FAILURE([cannot determine vmod installation directory]) 119 AC_MSG_FAILURE([cannot determine vmod installation directory])
100 fi]) 120 fi])
@@ -126,10 +146,12 @@ AC_CONFIG_COMMANDS([status],[
126delim="-------------------------------------------------------------------" 146delim="-------------------------------------------------------------------"
127echo "" 147echo ""
128echo $delim 148echo $delim
129echo "Building for Varnish version $VARNISHVERSION" 149echo "Building for Varnish version $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR"
130echo $delim 150echo $delim
131], 151],
132[VARNISHVERSION=$VARNISHVERSION]) 152[VARNISHAPI_MAJOR=$VARNISHAPI_MAJOR
153VARNISHAPI_MINOR=$VARNISHAPI_MINOR
154])
133 155
134AC_CONFIG_FILES([ 156AC_CONFIG_FILES([
135 Makefile 157 Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 214af8f..7d4e194 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,21 +41,10 @@ tbf.lo: vcc_if.h
41 41
42CLEANFILES = vcc_if.c vcc_if.h *.rst 42CLEANFILES = vcc_if.c vcc_if.h *.rst
43 43
44if VARNISH4 44vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py
45 vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py 45vmodtoolargs = --strict
46 vmodtoolargs = --strict 46vccfile = $(top_srcdir)/src/vmod_tbf.vcc
47 vccfile = $(top_srcdir)/src/vmod_tbf.vcc
48else
49 vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py
50 vmodtoolargs =
51 vccfile = vmod_tbf.vcc3
52 47
53vmod_tbf.vcc3: $(top_srcdir)/src/vmod_tbf.vcc
54 CLEANFILES += vmod_tbf.vcc3
55endif
56
57.vcc.vcc3:
58 sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@
59vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) 48vcc_if.c vcc_if.h: $(vmodtool) $(vccfile)
60 @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) 49 @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile)
61 50
diff --git a/src/tbf.h b/src/tbf.h
index 69e1262..7ee9f7e 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -1,5 +1,5 @@
1/* This file is part of vmod-tbf 1/* This file is part of vmod-tbf
2 Copyright (C) 2013-2014 Sergey Poznyakoff 2 Copyright (C) 2013-2016 Sergey Poznyakoff
3 3
4 Vmod-tbf is free software; you can redistribute it and/or modify 4 Vmod-tbf is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -25,17 +25,7 @@
25#include "vrt.h" 25#include "vrt.h"
26#include "vcc_if.h" 26#include "vcc_if.h"
27#include "pthread.h" 27#include "pthread.h"
28#if VARNISHVERSION == 3 28
29# include "bin/varnishd/cache.h" 29#include "bin/varnishd/cache/cache.h"
30# define VCL_VOID void 30#define MOD_CTX const struct vrt_ctx *
31# define VCL_INT int 31#define WSPTR(s) ((s)->ws)
32# define VCL_REAL double
33# define VCL_BOOL unsigned
34# define VCL_STRING const char *
35# define MOD_CTX struct sess *
36# define WSPTR(s) ((s)->wrk->ws)
37#else
38# include "bin/varnishd/cache/cache.h"
39# define MOD_CTX const struct vrt_ctx *
40# define WSPTR(s) ((s)->ws)
41#endif
diff --git a/src/vmod-tbf.3 b/src/vmod-tbf.3
index 03d7daf..0b5a99d 100644
--- a/src/vmod-tbf.3
+++ b/src/vmod-tbf.3
@@ -206,7 +206,7 @@ of time.
206.\" for man-based doc pages. 206.\" for man-based doc pages.
207.if "\V[MANCGI]"WEBDOC" \{\ 207.if "\V[MANCGI]"WEBDOC" \{\
208. ds package vmod-tbf 208. ds package vmod-tbf
209. ds version 1.0 209. ds version 2.0
210. so download.inc 210. so download.inc
211\} 211\}
212.SH "SEE ALSO" 212.SH "SEE ALSO"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c252b02..3c80a55 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,29 +14,14 @@
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>. 15# along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>.
16 16
17VMOD_VTC = \
18 test01.vtc\
19 test03.vtc\
20 time00.vtc
21
22VMOD_VTI = \
23 test00.vti\
24 test02.vti
25
26BUILT_TESTS = $(VMOD_VTI:.vti=.vtc)
27
28VMOD_TESTS = \ 17VMOD_TESTS = \
29 test00.vti\ 18 test00.vtc\
30 test01.vtc\ 19 test01.vtc\
31 test02.vti\ 20 test02.vtc\
32 test03.vtc\ 21 test03.vtc\
33 time00.vtc 22 time00.vtc
34 23
35.vti.vtc: 24EXTRA_DIST=$(VMOD_TESTS)
36 sed 's/^#VARNISH$(VARNISHVERSION)#//' $< > $@
37
38EXTRA_DIST=$(VMOD_VTC) $(VMOD_VTI)
39CLEANFILES=$(BUILT_TESTS)
40 25
41distclean-local: 26distclean-local:
42 rm -fr tbf 27 rm -fr tbf
diff --git a/tests/test00.vti b/tests/test00.vtc
index 53b9049..54c0281 100644
--- a/tests/test00.vti
+++ b/tests/test00.vtc
@@ -1,5 +1,5 @@
1# This file is part of vmod-tbf 1# This file is part of vmod-tbf
2# Copyright (C) 2013-2014 Sergey Poznyakoff 2# Copyright (C) 2013-2016 Sergey Poznyakoff
3# 3#
4# Vmod-tbf is free software; you can redistribute it and/or modify 4# Vmod-tbf is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
@@ -31,11 +31,9 @@ varnish v1 -vcl+backend {
31 } 31 }
32 sub vcl_recv { 32 sub vcl_recv {
33 if (!tbf.rate("url:"+req.url, 1, 20 s, 5)) { 33 if (!tbf.rate("url:"+req.url, 1, 20 s, 5)) {
34#VARNISH3# error 420 "Overlimit"; 34 return (synth(420, "Overlimit"));
35#VARNISH4# return (synth(420, "Overlimit"));
36 } 35 }
37#VARNISH3# return (lookup); 36 return (hash);
38#VARNISH4# return (hash);
39 } 37 }
40} -start 38} -start
41 39
diff --git a/tests/test02.vti b/tests/test02.vtc
index ef58fb8..8ff3c51 100644
--- a/tests/test02.vti
+++ b/tests/test02.vtc
@@ -1,5 +1,5 @@
1# This file is part of vmod-tbf 1# This file is part of vmod-tbf
2# Copyright (C) 2013-2014 Sergey Poznyakoff 2# Copyright (C) 2013-2016<