aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS7
-rw-r--r--configure.ac13
-rw-r--r--src/.gitignore2
-rw-r--r--src/Makefile.am37
-rw-r--r--src/binlog.c64
-rw-r--r--src/vmod-binlog.h3
-rw-r--r--src/vmod.vcc111
-rw-r--r--tests/atlocal.in3
-rw-r--r--tests/test01.at2
-rw-r--r--tests/test02.at2
10 files changed, 191 insertions, 53 deletions
diff --git a/NEWS b/NEWS
index e8b0f8b..9d04eb8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,13 @@
1Vmod-binlog NEWS -- history of user-visible changes. 2014-05-29 1Vmod-binlog NEWS -- history of user-visible changes. 2014-11-01
2Copyright (C) 2013 Sergey Poznyakoff 2Copyright (C) 2013 Sergey Poznyakoff
3See the end of file for copying conditions. 3See the end of file for copying conditions.
4 4
5Please send Vmod-binlog bug reports to <gray@gnu.org> 5Please send Vmod-binlog bug reports to <gray@gnu.org>
6 6
7Version 1,0.90 (Git) 7Version 1,0.91 (Git)
8
9Support for VCL 4.0
10
8 11
9Version 1.0, 2013-10-19 12Version 1.0, 2013-10-19
10 13
diff --git a/configure.ac b/configure.ac
index 3d80940..090f710 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,7 @@
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/>.
16AC_PREREQ(2.69) 16AC_PREREQ(2.69)
17AC_INIT([vmod-binlog], 1.0.90, [gray@gnu.org]) 17AC_INIT([vmod-binlog], 1.0.91, [gray@gnu.org])
18AC_CONFIG_AUX_DIR([build-aux]) 18AC_CONFIG_AUX_DIR([build-aux])
19AC_CONFIG_MACRO_DIR([m4]) 19AC_CONFIG_MACRO_DIR([m4])
20AC_CONFIG_SRCDIR(src/binlog.c) 20AC_CONFIG_SRCDIR(src/binlog.c)
@@ -73,9 +73,16 @@ case "$VARNISHSRC" in
73esac 73esac
74 74
75VARNISHSRC=`cd $VARNISHSRC && pwd` 75VARNISHSRC=`cd $VARNISHSRC && pwd`
76VARNISHVERSION=
76AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], 77AC_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
83AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number])
84AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3])
85AM_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
81AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], 88AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
diff --git a/src/.gitignore b/src/.gitignore
index 8f5a6ab..bae35ac 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -3,3 +3,5 @@ binlogsel
3parse-datetime.c 3parse-datetime.c
4vcc_if.c 4vcc_if.c
5vcc_if.h 5vcc_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,5 +1,5 @@
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
@@ -14,7 +14,10 @@
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
17AM_CPPFLAGS = -I$(VARNISHSRC)/include -I$(VARNISHSRC) 17AM_CPPFLAGS =\
18 -I$(VARNISHSRC)/include\
19 -I$(VARNISHSRC)/bin/varnishd\
20 -I$(VARNISHSRC)
18 21
19noinst_LIBRARIES = libbinlog.a 22noinst_LIBRARIES = libbinlog.a
20libbinlog_a_SOURCES = pack.c err.c parse-datetime.y xalloc.c 23libbinlog_a_SOURCES = pack.c err.c parse-datetime.y xalloc.c
@@ -38,17 +41,33 @@ libvmod_binlog_la_LIBADD=
38libvmod_binlog_la_SOURCES = \ 41libvmod_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 45nodist_libvmod_binlog_la_SOURCES = vcc_if.c vcc_if.h
43
44noinst_HEADERS = pack.h err.h parse-datetime.h xalloc.h 46noinst_HEADERS = pack.h err.h parse-datetime.h xalloc.h
45 47
46BUILT_SOURCES = vcc_if.c vcc_if.h 48binlog.lo: vcc_if.c vcc_if.h
49
50CLEANFILES = vcc_if.c vcc_if.h *.rst
51
52if VARNISH4
53 vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py
54 vmodtoolargs = --strict
55 vccfile = $(top_srcdir)/src/vmod.vcc
56else
57 vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py
58 vmodtoolargs =
59 vccfile = vmod.vcc3
60
61vmod.vcc3: $(top_srcdir)/src/vmod.vcc
62 CLEANFILES += vmod.vcc3
63endif
64
65.vcc.vcc3:
66 sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@
47 67
48vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc 68vcc_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
51EXTRA_DIST = vmod.vcc 71EXTRA_DIST = vmod.vcc
52 72
53CLEANFILES = $(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
@@ -29,9 +29,20 @@
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#if VARNISHVERSION == 3
32# include "bin/varnishd/cache.h" 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
@@ -262,7 +273,7 @@ make_key()
262} 273}
263 274
264void 275void
265vmod_init(struct sess *sp, struct vmod_priv *priv, 276vmod_init(MOD_CTX ctx, struct vmod_priv *priv,
266 const char *dir, const char *format, const char *param) 277 const char *dir, const char *format, const char *param)
267{ 278{
268 struct binlog_config *conf = priv->priv; 279 struct binlog_config *conf = priv->priv;
@@ -352,7 +363,6 @@ vmod_init(struct sess *sp, struct vmod_priv *priv,
352 binlog_error("invalid size value"); 363 binlog_error("invalid size value");
353 abort(); 364 abort();
354 } 365 }
355 free(p);
356 switch (*q) { 366 switch (*q) {
357 case 'g': 367 case 'g':
358 case 'G': 368 case 'G':
@@ -369,6 +379,7 @@ vmod_init(struct sess *sp, struct vmod_priv *priv,
369 abort(); 379 abort();
370 } 380 }
371 conf->size = u; 381 conf->size = u;
382 free(p);
372 } else 383 } else
373 conf->size = BINLOG_SIZE; 384 conf->size = BINLOG_SIZE;
374 385
@@ -426,7 +437,7 @@ vmod_init(struct sess *sp, struct vmod_priv *priv,
426} 437}
427 438
428static char * 439static char *
429mkfilename(struct sess *sp, struct binlog_config *conf) 440mkfilename(MOD_CTX ctx, struct binlog_config *conf)
430{ 441{
431 time_t ts = time(NULL); 442 time_t ts = time(NULL);
432 size_t u, n; 443 size_t u, n;
@@ -434,16 +445,16 @@ mkfilename(struct sess *sp, struct binlog_config *conf)
434 445
435 if (conf->flags & BLF_ROUNDTS) 446 if (conf->flags & BLF_ROUNDTS)
436 ts -= ts % conf->interval; 447 ts -= ts % conf->interval;
437 u = WS_Reserve(sp->wrk->ws, 0); 448 u = WS_Reserve(WSPTR(ctx), 0);
438 p = sp->wrk->ws->f; 449 p = WSPTR(ctx)->f;
439 n = strftime(p, u, conf->pattern, gmtime(&ts)); 450 n = strftime(p, u, conf->pattern, gmtime(&ts));
440 if (n == 0) { 451 if (n == 0) {
441 WS_Release(sp->wrk->ws, 0); 452 WS_Release(WSPTR(ctx), 0);
442 return NULL; 453 return NULL;
443 } 454 }
444 q = strdup(p); 455 q = strdup(p);
445 AN(q); 456 AN(q);
446 WS_Release(sp->wrk->ws, 0); 457 WS_Release(WSPTR(ctx), 0);
447 return q; 458 return q;
448} 459}
449 460
@@ -481,7 +492,7 @@ mkdir_p(struct binlog_config *conf, char *dir)
481} 492}
482 493