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 @@
# This file is part of vmod-tbf -*- autoconf -*-
-# Copyright (C) 2013-2014 Sergey Poznyakoff
+# Copyright (C) 2013-2016 Sergey Poznyakoff
#
# Vmod-tbf is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -67,17 +67,37 @@ case "$VARNISHSRC" in
esac
VARNISHSRC=`cd $VARNISHSRC && pwd`
-VARNISHVERSION=
-AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
- [VARNISHVERSION=3],
- [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h],
- [VARNISHVERSION=4],
- [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ])
-AC_SUBST([VARNISHVERSION],$VARNISHVERSION)
-
-AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number])
-AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3])
-AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4])
+
+
+# pkg-config
+PKG_PROG_PKG_CONFIG
+PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
+
+varnishapi_version() {
+ VARNISHAPI_MAJOR=$1
+ VARNISHAPI_MINOR=$2
+ VARNISHAPI_PATCH=$3
+}
+
+v=$($PKG_CONFIG --modversion varnishapi)
+if test -n "$v"; then
+ save_IFS=$IFS
+ IFS='.'
+ varnishapi_version $v
+ IFS=$save_IFS
+else
+ AC_MSG_ERROR([unknown varnishapi version])
+fi
+
+if test $VARNISHAPI_MAJOR -ne 4; then
+ AC_MSG_ERROR([unsupported varnishapi version])
+fi
+
+case $VARNISHAPI_MINOR in
+0) AC_MSG_ERROR([unsupported varnishapi version]);;
+1) ;;
+*) AC_MSG_WARN([varnishapi minor version probably unsupported])
+esac
# Check that varnishtest is built in the varnish source directory
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
@@ -94,7 +114,7 @@ AC_ARG_WITH([vmoddir],
/*) VMODDIR=$withval;;
no) unset VMODDIR;;
*) AC_MSG_ERROR([argument to --with-vmoddir must be absolute pathname])
- esac],[VMODDIR=`pkg-config --variable=vmoddir varnishapi`
+ esac],[VMODDIR=$($PKG_CONFIG --variable=vmoddir varnishapi)
if test -z "$VMODDIR"; then
AC_MSG_FAILURE([cannot determine vmod installation directory])
fi])
@@ -126,10 +146,12 @@ AC_CONFIG_COMMANDS([status],[
delim="-------------------------------------------------------------------"
echo ""
echo $delim
-echo "Building for Varnish version $VARNISHVERSION"
+echo "Building for Varnish version $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR"
echo $delim
],
-[VARNISHVERSION=$VARNISHVERSION])
+[VARNISHAPI_MAJOR=$VARNISHAPI_MAJOR
+VARNISHAPI_MINOR=$VARNISHAPI_MINOR
+])
AC_CONFIG_FILES([
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
CLEANFILES = vcc_if.c vcc_if.h *.rst
-if VARNISH4
- vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py
- vmodtoolargs = --strict
- vccfile = $(top_srcdir)/src/vmod_tbf.vcc
-else
- vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py
- vmodtoolargs =
- vccfile = vmod_tbf.vcc3
+vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py
+vmodtoolargs = --strict
+vccfile = $(top_srcdir)/src/vmod_tbf.vcc
-vmod_tbf.vcc3: $(top_srcdir)/src/vmod_tbf.vcc
- CLEANFILES += vmod_tbf.vcc3
-endif
-
-.vcc.vcc3:
- sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@
vcc_if.c vcc_if.h: $(vmodtool) $(vccfile)
@PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile)
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 @@
/* This file is part of vmod-tbf
- Copyright (C) 2013-2014 Sergey Poznyakoff
+ Copyright (C) 2013-2016 Sergey Poznyakoff
Vmod-tbf is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,17 +25,7 @@
#include "vrt.h"
#include "vcc_if.h"
#include "pthread.h"
-#if VARNISHVERSION == 3
-# include "bin/varnishd/cache.h"
-# define VCL_VOID void
-# define VCL_INT int
-# define VCL_REAL double
-# define VCL_BOOL unsigned
-# define VCL_STRING const char *
-# define MOD_CTX struct sess *
-# define WSPTR(s) ((s)->wrk->ws)
-#else
-# include "bin/varnishd/cache/cache.h"
-# define MOD_CTX const struct vrt_ctx *
-# define WSPTR(s) ((s)->ws)
-#endif
+
+#include "bin/varnishd/cache/cache.h"
+#define MOD_CTX const struct vrt_ctx *
+#define WSPTR(s) ((s)->ws)
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.
.\" for man-based doc pages.
.if "\V[MANCGI]"WEBDOC" \{\
. ds package vmod-tbf
-. ds version 1.0
+. ds version 2.0
. so download.inc
\}
.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 @@
# You should have received a copy of the GNU General Public License
# along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>.
-VMOD_VTC = \
- test01.vtc\
- test03.vtc\
- time00.vtc
-
-VMOD_VTI = \
- test00.vti\
- test02.vti
-
-BUILT_TESTS = $(VMOD_VTI:.vti=.vtc)
-
VMOD_TESTS = \
- test00.vti\
+ test00.vtc\
test01.vtc\
- test02.vti\
+ test02.vtc\
test03.vtc\
time00.vtc
-.vti.vtc:
- sed 's/^#VARNISH$(VARNISHVERSION)#//' $< > $@
-
-EXTRA_DIST=$(VMOD_VTC) $(VMOD_VTI)
-CLEANFILES=$(BUILT_TESTS)
+EXTRA_DIST=$(VMOD_TESTS)
distclean-local:
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 @@
# This file is part of vmod-tbf
-# Copyright (C) 2013-2014 Sergey Poznyakoff
+# Copyright (C) 2013-2016 Sergey Poznyakoff
#
# Vmod-tbf is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,11 +31,9 @@ varnish v1 -vcl+backend {
}
sub vcl_recv {
if (!tbf.rate("url:"+req.url, 1, 20 s, 5)) {
-#VARNISH3# error 420 "Overlimit";
-#VARNISH4# return (synth(420, "Overlimit"));
+ return (synth(420, "Overlimit"));
}
-#VARNISH3# return (lookup);
-#VARNISH4# return (hash);
+ return (hash);
}
} -start
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 @@
# This file is part of vmod-tbf
-# Copyright (C) 2013-2014 Sergey Poznyakoff
+# Copyright (C) 2013-2016 Sergey Poznyakoff
#
# Vmod-tbf is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,11 +31,9 @@ varnish v1 -vcl+backend {
}
sub vcl_recv {
if (!tbf.check("url:"+req.url, "4 req/s")) {
-#VARNISH3# error 420 "Overlimit";
-#VARNISH4# return (synth(420, "Overlimit"));
+ return (synth(420, "Overlimit"));
}
-#VARNISH3# return (lookup);
-#VARNISH4# return (hash);
+ return (hash);
}
} -start

Return to:

Send suggestions and report system problems to the System administrator.