diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-20 14:10:33 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-20 14:10:33 +0200 |
commit | 741817ac5372c374b52b710dd8a4b0cc463ade99 (patch) | |
tree | 46343899a7e7249c8306e227a59dabc4e9e04dec | |
parent | 67731a160cc7c3e090236316af459f695593fc55 (diff) | |
download | vmod-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.ac | 52 | ||||
-rw-r--r-- | src/Makefile.am | 17 | ||||
-rw-r--r-- | src/tbf.h | 20 | ||||
-rw-r--r-- | src/vmod-tbf.3 | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 21 | ||||
-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 | |||
67 | esac | 67 | esac |
68 | 68 | ||
69 | VARNISHSRC=`cd $VARNISHSRC && pwd` | 69 | VARNISHSRC=`cd $VARNISHSRC && pwd` |
70 | VARNISHVERSION= | 70 | |
71 | AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], | 71 | |
72 | [VARNISHVERSION=3], | 72 | # pkg-config |
73 | [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h], | 73 | PKG_PROG_PKG_CONFIG |
74 | [VARNISHVERSION=4], | 74 | PKG_CHECK_MODULES([libvarnishapi], [varnishapi]) |
75 | [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ]) | 75 | |
76 | AC_SUBST([VARNISHVERSION],$VARNISHVERSION) | 76 | varnishapi_version() { |
77 | 77 | VARNISHAPI_MAJOR=$1 | |
78 | AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) | 78 | VARNISHAPI_MINOR=$2 |
79 | AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) | 79 | VARNISHAPI_PATCH=$3 |
80 | AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) | 80 | } |
81 | |||
82 | v=$($PKG_CONFIG --modversion varnishapi) | ||
83 | if test -n "$v"; then | ||
84 | save_IFS=$IFS | ||
85 | IFS='.' | ||
86 | varnishapi_version $v | ||
87 | IFS=$save_IFS | ||
88 | else | ||
89 | AC_MSG_ERROR([unknown varnishapi version]) | ||
90 | fi | ||
91 | |||
92 | if test $VARNISHAPI_MAJOR -ne 4; then | ||
93 | AC_MSG_ERROR([unsupported varnishapi version]) | ||
94 | fi | ||
95 | |||
96 | case $VARNISHAPI_MINOR in | ||
97 | 0) AC_MSG_ERROR([unsupported varnishapi version]);; | ||
98 | 1) ;; | ||
99 | *) AC_MSG_WARN([varnishapi minor version probably unsupported]) | ||
100 | esac | ||
81 | 101 | ||
82 | # Check that varnishtest is built in the varnish source directory | 102 | # Check that varnishtest is built in the varnish source directory |
83 | AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], | 103 | AC_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],[ | |||
126 | delim="-------------------------------------------------------------------" | 146 | delim="-------------------------------------------------------------------" |
127 | echo "" | 147 | echo "" |
128 | echo $delim | 148 | echo $delim |
129 | echo "Building for Varnish version $VARNISHVERSION" | 149 | echo "Building for Varnish version $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR" |
130 | echo $delim | 150 | echo $delim |
131 | ], | 151 | ], |
132 | [VARNISHVERSION=$VARNISHVERSION]) | 152 | [VARNISHAPI_MAJOR=$VARNISHAPI_MAJOR |
153 | VARNISHAPI_MINOR=$VARNISHAPI_MINOR | ||
154 | ]) | ||
133 | 155 | ||
134 | AC_CONFIG_FILES([ | 156 | AC_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 | ||
42 | CLEANFILES = vcc_if.c vcc_if.h *.rst | 42 | CLEANFILES = vcc_if.c vcc_if.h *.rst |
43 | 43 | ||
44 | if VARNISH4 | 44 | vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py |
45 | vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py | 45 | vmodtoolargs = --strict |
46 | vmodtoolargs = --strict | 46 | vccfile = $(top_srcdir)/src/vmod_tbf.vcc |
47 | vccfile = $(top_srcdir)/src/vmod_tbf.vcc | ||
48 | else | ||
49 | vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py | ||
50 | vmodtoolargs = | ||
51 | vccfile = vmod_tbf.vcc3 | ||
52 | 47 | ||
53 | vmod_tbf.vcc3: $(top_srcdir)/src/vmod_tbf.vcc | ||
54 | CLEANFILES += vmod_tbf.vcc3 | ||
55 | endif | ||
56 | |||
57 | .vcc.vcc3: | ||
58 | sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@ | ||
59 | vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) | 48 | vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) |
60 | @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) | 49 | @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) |
61 | 50 | ||
@@ -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 | ||
17 | VMOD_VTC = \ | ||
18 | test01.vtc\ | ||
19 | test03.vtc\ | ||
20 | time00.vtc | ||
21 | |||
22 | VMOD_VTI = \ | ||
23 | test00.vti\ | ||
24 | test02.vti | ||
25 | |||
26 | BUILT_TESTS = $(VMOD_VTI:.vti=.vtc) | ||
27 | |||
28 | VMOD_TESTS = \ | 17 | VMOD_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: | 24 | EXTRA_DIST=$(VMOD_TESTS) |
36 | sed 's/^#VARNISH$(VARNISHVERSION)#//' $< > $@ | ||
37 | |||
38 | EXTRA_DIST=$(VMOD_VTC) $(VMOD_VTI) | ||
39 | CLEANFILES=$(BUILT_TESTS) | ||
40 | 25 | ||
41 | distclean-local: | 26 | distclean-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< |