diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-01 16:28:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-11-01 16:34:10 +0200 |
commit | fffbbfb089847644e2b0281faba2fa892df4f8b9 (patch) | |
tree | 83899ca03d92bdb4100c413904c83385ca0c7d6c | |
parent | c16de06862f9b2106dcb7810fc20856689ef2aa6 (diff) | |
download | vmod-binlog-fffbbfb089847644e2b0281faba2fa892df4f8b9.tar.gz vmod-binlog-fffbbfb089847644e2b0281faba2fa892df4f8b9.tar.bz2 |
Support for VCL 4.0
* configure.ac: Version 1.0.91
Detect varnish version and set variables and conditionals accordingly.
* NEWS: Update.
* src/.gitignore: Update.
* src/Makefile.am: Always build vcc_if.c and vcc_if.h. Don't
distribute them.
* src/binlog.c: Use VCL data type. Define them for VCL 3.0.
(vmod_init): Fix premature memory deallocation.
* src/vmod.vcc: Rewrite in VCL 4.0 syntax.
* tests/atlocal.in (ret_vcl_recv): New variable.
* tests/test01.at (vcl_recv): Return $ret_vcl_recv.
* tests/test02.at: Likewise.
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | src/.gitignore | 2 | ||||
-rw-r--r-- | src/Makefile.am | 37 | ||||
-rw-r--r-- | src/binlog.c | 66 | ||||
-rw-r--r-- | src/vmod-binlog.h | 3 | ||||
-rw-r--r-- | src/vmod.vcc | 111 | ||||
-rw-r--r-- | tests/atlocal.in | 3 | ||||
-rw-r--r-- | tests/test01.at | 2 | ||||
-rw-r--r-- | tests/test02.at | 2 |
10 files changed, 192 insertions, 54 deletions
@@ -1,13 +1,16 @@ | |||
1 | Vmod-binlog NEWS -- history of user-visible changes. 2014-05-29 | 1 | Vmod-binlog NEWS -- history of user-visible changes. 2014-11-01 |
2 | Copyright (C) 2013 Sergey Poznyakoff | 2 | Copyright (C) 2013 Sergey Poznyakoff |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
5 | Please send Vmod-binlog bug reports to <gray@gnu.org> | 5 | Please send Vmod-binlog bug reports to <gray@gnu.org> |
6 | 6 | ||
7 | Version 1,0.90 (Git) | 7 | Version 1,0.91 (Git) |
8 | |||
9 | Support for VCL 4.0 | ||
10 | |||
8 | 11 | ||
9 | Version 1.0, 2013-10-19 | 12 | Version 1.0, 2013-10-19 |
10 | 13 | ||
11 | Initial release. | 14 | Initial release. |
12 | 15 | ||
13 | 16 | ||
diff --git a/configure.ac b/configure.ac index 3d80940..090f710 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -11,13 +11,13 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
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-binlog. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. |
16 | AC_PREREQ(2.69) | 16 | AC_PREREQ(2.69) |
17 | AC_INIT([vmod-binlog], 1.0.90, [gray@gnu.org]) | 17 | AC_INIT([vmod-binlog], 1.0.91, [gray@gnu.org]) |
18 | AC_CONFIG_AUX_DIR([build-aux]) | 18 | AC_CONFIG_AUX_DIR([build-aux]) |
19 | AC_CONFIG_MACRO_DIR([m4]) | 19 | AC_CONFIG_MACRO_DIR([m4]) |
20 | AC_CONFIG_SRCDIR(src/binlog.c) | 20 | AC_CONFIG_SRCDIR(src/binlog.c) |
21 | AM_CONFIG_HEADER(config.h) | 21 | AM_CONFIG_HEADER(config.h) |
22 | 22 | ||
23 | AC_CANONICAL_SYSTEM | 23 | AC_CANONICAL_SYSTEM |
@@ -70,15 +70,22 @@ fi | |||
70 | case "$VARNISHSRC" in | 70 | case "$VARNISHSRC" in |
71 | /*) ;; | 71 | /*) ;; |
72 | *) AC_MSG_ERROR([varnish source path must be absolute pathname]) | 72 | *) AC_MSG_ERROR([varnish source path must be absolute pathname]) |
73 | esac | 73 | esac |
74 | 74 | ||
75 | VARNISHSRC=`cd $VARNISHSRC && pwd` | 75 | VARNISHSRC=`cd $VARNISHSRC && pwd` |
76 | VARNISHVERSION= | ||
76 | AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], | 77 | AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], |
77 | [], | 78 | [VARNISHVERSION=3], |
78 | [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) | 79 | [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h], |
80 | [VARNISHVERSION=4], | ||
81 | [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ]) | ||
82 | |||
83 | AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) | ||
84 | AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) | ||
85 | AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) | ||
79 | 86 | ||
80 | # Check that varnishtest is built in the varnish source directory | 87 | # Check that varnishtest is built in the varnish source directory |
81 | AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], | 88 | AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], |
82 | [], | 89 | [], |
83 | [AC_MSG_FAILURE([cannot find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])] | 90 | [AC_MSG_FAILURE([cannot find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])] |
84 | ) | 91 | ) |
diff --git a/src/.gitignore b/src/.gitignore index 8f5a6ab..bae35ac 100644 --- a/src/.gitignore +++ b/src/.gitignore | |||
@@ -1,5 +1,7 @@ | |||
1 | binlogcat | 1 | binlogcat |
2 | binlogsel | 2 | binlogsel |
3 | parse-datetime.c | 3 | parse-datetime.c |
4 | vcc_if.c | 4 | vcc_if.c |
5 | vcc_if.h | 5 | vcc_if.h |
6 | *.rst | ||
7 | *.vcc3 | ||
diff --git a/src/Makefile.am b/src/Makefile.am index a20f9cb..7917730 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of vmod-binlog | 1 | # This file is part of vmod-binlog |
2 | # Copyright (C) 2013 Sergey Poznyakoff | 2 | # Copyright (C) 2013-2014 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Vmod-binlog is free software; you can redistribute it and/or modify | 4 | # Vmod-binlog 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 |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -11,13 +11,16 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
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-binlog. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AM_CPPFLAGS = -I$(VARNISHSRC)/include -I$(VARNISHSRC) | 17 | AM_CPPFLAGS =\ |
18 | -I$(VARNISHSRC)/include\ | ||
19 | -I$(VARNISHSRC)/bin/varnishd\ | ||
20 | -I$(VARNISHSRC) | ||
18 | 21 | ||
19 | noinst_LIBRARIES = libbinlog.a | 22 | noinst_LIBRARIES = libbinlog.a |
20 | libbinlog_a_SOURCES = pack.c err.c parse-datetime.y xalloc.c | 23 | libbinlog_a_SOURCES = pack.c err.c parse-datetime.y xalloc.c |
21 | libbinlog_a_CFLAGS = $(AM_CFLAGS) | 24 | libbinlog_a_CFLAGS = $(AM_CFLAGS) |
22 | 25 | ||
23 | bin_PROGRAMS = binlogcat binlogsel | 26 | bin_PROGRAMS = binlogcat binlogsel |
@@ -35,20 +38,36 @@ vmod_LTLIBRARIES = libvmod_binlog.la | |||
35 | libvmod_binlog_la_LDFLAGS = -module -export-dynamic -avoid-version | 38 | libvmod_binlog_la_LDFLAGS = -module -export-dynamic -avoid-version |
36 | libvmod_binlog_la_LIBADD= | 39 | libvmod_binlog_la_LIBADD= |
37 | 40 | ||
38 | libvmod_binlog_la_SOURCES = \ | 41 | libvmod_binlog_la_SOURCES = \ |
39 | binlog.c\ | 42 | binlog.c\ |
40 | pack.c\ | 43 | pack.c\ |
41 | vmod-binlog.h\ | 44 | vmod-binlog.h |
42 | vcc_if.c vcc_if.h | 45 | nodist_libvmod_binlog_la_SOURCES = vcc_if.c vcc_if.h |
43 | |||
44 | noinst_HEADERS = pack.h err.h parse-datetime.h xalloc.h | 46 | noinst_HEADERS = pack.h err.h parse-datetime.h xalloc.h |
45 | 47 | ||
46 | BUILT_SOURCES = vcc_if.c vcc_if.h | 48 | binlog.lo: vcc_if.c vcc_if.h |
49 | |||
50 | CLEANFILES = vcc_if.c vcc_if.h *.rst | ||
51 | |||
52 | if VARNISH4 | ||
53 | vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py | ||
54 | vmodtoolargs = --strict | ||
55 | vccfile = $(top_srcdir)/src/vmod.vcc | ||
56 | else | ||
57 | vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py | ||
58 | vmodtoolargs = | ||
59 | vccfile = vmod.vcc3 | ||
60 | |||
61 | vmod.vcc3: $(top_srcdir)/src/vmod.vcc | ||
62 | CLEANFILES += vmod.vcc3 | ||
63 | endif | ||
64 | |||
65 | .vcc.vcc3: | ||
66 | sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@ | ||
47 | 67 | ||
48 | vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc | 68 | vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) |
49 | @PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc | 69 | @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) |
50 | 70 | ||
51 | EXTRA_DIST = vmod.vcc | 71 | EXTRA_DIST = vmod.vcc |
52 | 72 | ||
53 | CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h | ||
54 | 73 | ||
diff --git a/src/binlog.c b/src/binlog.c index 45299f2..e9fb16e 100644 --- a/src/binlog.c +++ b/src/binlog.c | |||
@@ -26,15 +26,26 @@ | |||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <stdarg.h> | 27 | #include <stdarg.h> |
28 | #include <ctype.h> | 28 | #include <ctype.h> |
29 | #include <time.h> | 29 | #include <time.h> |
30 | #include "vrt.h" | 30 | #include "vrt.h" |
31 | #include "vcc_if.h" | 31 | #include "vcc_if.h" |
32 | #include "bin/varnishd/cache.h" | 32 | #if VARNISHVERSION == 3 |
33 | # include "bin/varnishd/cache.h" | ||
34 | # define VCL_VOID void | ||
35 | # define VCL_STRING const char * | ||
36 | # define MOD_CTX struct sess * | ||
37 | # define WSPTR(s) ((s)->wrk->ws) | ||
38 | #else | ||
39 | # include "bin/varnishd/cache/cache.h" | ||
40 | # define MOD_CTX const struct vrt_ctx * | ||
41 | # define WSPTR(s) ((s)->ws) | ||
42 | #endif | ||
33 | #include "vmod-binlog.h" | 43 | #include "vmod-binlog.h" |
34 | #include "pack.h" | 44 | #include "pack.h" |
45 | #include "pthread.h" | ||
35 | 46 | ||
36 | #ifndef O_SEARCH | 47 | #ifndef O_SEARCH |
37 | # define O_SEARCH 0 | 48 | # define O_SEARCH 0 |
38 | #endif | 49 | #endif |
39 | 50 | ||
40 | #define BLF_ROUNDTS 0x01 | 51 | #define BLF_ROUNDTS 0x01 |
@@ -259,13 +270,13 @@ static void | |||
259 | make_key() | 270 | make_key() |
260 | { | 271 | { |
261 | pthread_key_create(&thread_key, env_free); | 272 | pthread_key_create(&thread_key, env_free); |
262 | } | 273 | } |
263 | 274 | ||
264 | void | 275 | void |
265 | vmod_init(struct sess *sp, struct vmod_priv *priv, | 276 | vmod_init(MOD_CTX ctx, struct vmod_priv *priv, |
266 | const char *dir, const char *format, const char *param) |