diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | NEWS | 15 | ||||
m--------- | acvmod | 0 | ||||
-rw-r--r-- | configure.ac | 70 | ||||
-rw-r--r-- | src/Makefile.am | 22 | ||||
-rw-r--r-- | src/vmod-sql.c | 40 | ||||
-rw-r--r-- | src/vmod.vcc | 2 |
8 files changed, 44 insertions, 112 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..00ae21c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "acvmod"] + path = acvmod + url = git://git.gnu.org.ua/acvmod.git diff --git a/Makefile.am b/Makefile.am index 50edf73..25d4db4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # This file is part of vmod-sql -# Copyright (C) 2013-2014 Sergey Poznyakoff +# Copyright (C) 2013-2016 Sergey Poznyakoff # # Vmod-sql is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with vmod-sql. If not, see <http://www.gnu.org/licenses/>. -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I acvmod SUBDIRS = src doc #tests @@ -1,11 +1,18 @@ -vmod-sql -- history of user-visible changes. 2014-11-01 -Copyright (C) 2013-2014 Sergey Poznyakoff +vmod-sql -- history of user-visible changes. 2016-01-24 +Copyright (C) 2013-2016 Sergey Poznyakoff See the end of file for copying conditions. Please send vmod-sql bug reports to <gray@gnu.org> -Version 1.0.90 (git) +Version 1.0.90-4.1.0 (git) + +* Support for Varnish 4.1 + +* Versioning changes + +Starting with this release, the version number includes version +of Varnish API the release was designed for. Version 1.0, 2013-10-19 @@ -15,7 +22,7 @@ Initial release ========================================================================= Copyright information: -Copyright (C) 2013 Sergey Poznyakoff +Copyright (C) 2016 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff --git a/acvmod b/acvmod new file mode 160000 +Subproject f064cf4d7aa1ead1f8607b8b72baf883f015ffc diff --git a/configure.ac b/configure.ac index af14d73..c7188cb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # This file is part of vmod-sql -*- autoconf -*- -# Copyright (C) 2013-2014 Sergey Poznyakoff +# Copyright (C) 2013-2016 Sergey Poznyakoff # # Vmod-sql is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with vmod-sql. If not, see <http://www.gnu.org/licenses/>. AC_PREREQ(2.69) -AC_INIT([vmod-sql], 1.0.90, [gray@gnu.org]) +AC_INIT([vmod-sql], 1.0.90-4.1.0, [gray@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/vmod-sql.c) @@ -23,7 +23,8 @@ AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM AC_LANG(C) -AM_INIT_AUTOMAKE([1.14 gnu tar-ustar]) +AM_INIT_AUTOMAKE([1.14 gnu tar-ustar silent-rules]) +AM_SILENT_RULES([yes]) AC_GNU_SOURCE AC_PROG_CC @@ -37,68 +38,11 @@ AC_PROG_INSTALL AC_PROG_LIBTOOL AC_PROG_MAKE_SET -# Check for pkg-config -PKG_PROG_PKG_CONFIG - # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([sys/stdlib.h]) -# Check for python -AC_CHECK_PROGS(PYTHON, [python], [ - AC_MSG_ERROR([python is not found.])]) - -# Varnish source tree -AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree]) -AC_ARG_WITH([varnish-source], - AC_HELP_STRING([--with-varnish-source=DIR], - [Varnish sources are located in DIR]), - [VARNISHSRC=$withval]) - -if test -z "$VARNISHSRC"; then - AC_MSG_ERROR([no Varnish source tree specified]) -fi -case "$VARNISHSRC" in -/*) ;; -*) AC_MSG_ERROR([varnish source path must be absolute pathname]) -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_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) -AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) -AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) - -# Check that varnishtest is built in the varnish source directory -AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], - [], - [AC_MSG_FAILURE([cannot find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])] -) - -# vmod installation dir -AC_ARG_VAR([VMODDIR], [vmod installation directory]) -AC_ARG_WITH([vmoddir], - AC_HELP_STRING([--with-vmoddir=DIR], - [install modules to DIR]), - [case "$withval" in - /*) VMODDIR=$withval;; - no) unset VMODDIR;; - *) AC_MSG_ERROR([argument to --with-vmoddir must be absolute pathname]) - esac],[VMODDIR=`pkg-config --variable=vmoddir varnishapi` - if test -z "$VMODDIR"; then - AC_MSG_FAILURE([cannot determine vmod installation directory]) - fi]) - - -if test -z "$VMODDIR"; then - VMODDIR='$(libdir)/varnish/mods' -fi +AM_VARNISHAPI ########### # Check for SQL support @@ -160,11 +104,10 @@ AC_SUBST(PGSQLLIBS) AM_CONDITIONAL([USE_MYSQL],[test $build_mysql = yes]) AM_CONDITIONAL([USE_PGSQL],[test $build_pgsql = yes]) -AC_CONFIG_COMMANDS([status],[ +AC_CONFIG_COMMANDS([sqlstatus],[ echo "" delim="-------------------------------------------------------------------" echo $delim | tr '-' '*' -echo "Building for Varnish version $VARNISHVERSION" echo "Backends to build:" res= for module in mysql pgsql @@ -182,7 +125,6 @@ case "$res" in AC_MSG_ERROR([Nothing to build?]) esac ],[ -VARNISHVERSION=$VARNISHVERSION build_pgsql=$build_pgsql build_mysql=$build_mysql]) diff --git a/src/Makefile.am b/src/Makefile.am index 63346e2..601e8f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ # This file is part of vmod-sql -# Copyright (C) 2013-2014 Sergey Poznyakoff +# Copyright (C) 2013-2016 Sergey Poznyakoff # # Vmod-sql is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,24 +45,12 @@ vmod-sql.lo: vcc_if.c 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.vcc -else - vmodtool = $(VARNISHSRC)/lib/libvmod_std/vmod.py - vmodtoolargs = - vccfile = vmod.vcc3 +vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict +vccfile = $(top_srcdir)/src/vmod.vcc -vmod.vcc3: $(top_srcdir)/src/vmod.vcc - CLEANFILES += vmod.vcc3 -endif - -.vcc.vcc3: - sed -n '/^\$$/{s///;s/\(Module *[^ ][^ ]*\).*/\1/;p}' $< > $@ - vcc_if.c vcc_if.h: $(vmodtool) $(vccfile) - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vccfile) + $(AM_V_GEN)$(PYTHON) $(vmodtool) $(vmodtoolargs) $(vccfile) EXTRA_DIST = vmod.vcc diff --git a/src/vmod-sql.c b/src/vmod-sql.c index df5dae9..3dbfe4b 100644 --- a/src/vmod-sql.c +++ b/src/vmod-sql.c @@ -17,23 +17,13 @@ #include "vmod-sql.h" #include <stdarg.h> #include "wordsplit.h" +#include "vcl.h" #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_BOOL unsigned -# define VCL_STRING const char * -# define WS_Copy(w,s,l) WS_Dup(w,s) -# 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 WSPTR(s) ((s)->ws) static pthread_once_t thread_once = PTHREAD_ONCE_INIT; static pthread_key_t thread_key; @@ -126,9 +116,11 @@ make_key() } int -module_init(struct vmod_priv *priv, const struct VCL_conf *vclconf) +sql_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) { - pthread_once(&thread_once, make_key); + if (e == VCL_EVENT_LOAD) { + pthread_once(&thread_once, make_key); + } return 0; } @@ -170,7 +162,7 @@ find_backend(const char *name) } VCL_INT -vmod_connect(MOD_CTX ctx, struct vmod_priv *priv, +vmod_connect(VRT_CTX, struct vmod_priv *priv, VCL_STRING bkname, VCL_STRING param) { struct wordsplit ws; @@ -206,14 +198,14 @@ vmod_connect(MOD_CTX ctx, struct vmod_priv *priv, } VCL_VOID -vmod_connect_init(MOD_CTX ctx, struct vmod_priv *priv, +vmod_connect_init(VRT_CTX, struct vmod_priv *priv, VCL_STRING bkname, VCL_STRING param) { AZ(vmod_connect(ctx, priv, bkname, param)); } static struct vmod_sql_connection * -runquery(MOD_CTX ctx, int n, const char *query, const char *arg) +runquery(VRT_CTX, int n, const char *query, const char *arg) { struct vmod_sql_connection *cp; struct wordsplit ws, wsenv; @@ -271,14 +263,14 @@ runquery(MOD_CTX ctx, int n, const char *query, const char *arg) } VCL_BOOL -vmod_query(MOD_CTX ctx, struct vmod_priv *priv, +vmod_query(VRT_CTX, struct vmod_priv *priv, VCL_INT cd, VCL_STRING query, VCL_STRING arg) { return !runquery(ctx, cd, query, arg); } VCL_STRING -vmod_result(MOD_CTX ctx, struct vmod_priv *priv, +vmod_result(VRT_CTX, struct vmod_priv *priv, VCL_INT cd, VCL_INT row, VCL_INT col) { struct vmod_sql_connection *cp; @@ -296,7 +288,7 @@ vmod_result(MOD_CTX ctx, struct vmod_priv *priv, } VCL_INT -vmod_affected(MOD_CTX ctx, struct vmod_priv *priv, VCL_INT cd) +vmod_affected(VRT_CTX, struct vmod_priv *priv, VCL_INT cd) { struct vmod_sql_connection *cp; @@ -307,7 +299,7 @@ vmod_affected(MOD_CTX ctx, struct vmod_priv *priv, VCL_INT cd) } VCL_INT -vmod_ntuples(MOD_CTX ctx, struct vmod_priv *priv, VCL_INT cd) +vmod_ntuples(VRT_CTX, struct vmod_priv *priv, VCL_INT cd) { struct vmod_sql_connection *cp; @@ -318,7 +310,7 @@ vmod_ntuples(MOD_CTX ctx, struct vmod_priv *priv, VCL_INT cd) } VCL_INT -vmod_nfields(MOD_CTX ctx, struct vmod_priv *priv, VCL_INT cd) +vmod_nfields(VRT_CTX, struct vmod_priv *priv, VCL_INT cd) { struct vmod_sql_connection *cp; diff --git a/src/vmod.vcc b/src/vmod.vcc index 57869e0..f98ee87 100644 --- a/src/vmod.vcc +++ b/src/vmod.vcc @@ -29,7 +29,7 @@ DESCRIPTION Vmod-sql provides functions for accessing SQL databases from Varnish configuration files. It supports MySQL and PostgreSQL. -$Init module_init +$Event sql_event $Function INT connect(PRIV_VCL, STRING, STRING) Description |