diff --git a/configure.ac b/configure.ac index 270053d..c02bcb2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_PREREQ([2.63]) -AC_INIT([libvmod-soap], [1.0], [], [vmod-soap]) +AC_PREREQ([2.69]) +AC_INIT([libvmod-soap],[1.0],[],[vmod-soap]) AC_COPYRIGHT([Copyright (c) 2019, Refinitiv]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR(src/vmod_soap.vcc) -AC_CONFIG_HEADER([config.h]) +AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign parallel-tests]) AM_SILENT_RULES([yes]) @@ -24,28 +24,24 @@ AC_ARG_WITH([rst2man], [--with-rst2man=PATH], [Location of rst2man (auto)]), [RST2MAN="$withval"], - AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])) + [AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])]) m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.md])) -VARNISH_PREREQ([4.1], [5.0.0]) +VARNISH_PREREQ([4.1], [trunk]) VARNISH_VMODS([soap]) AC_SUBST([VARNISHSRC]) AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree]) AS_IF([test "x${VARNISHSRC}" = "x" ], AC_MSG_FAILURE([\$VARNISHSRC is not set]), AC_MSG_RESULT([yes])) AC_CHECK_FILE([$VARNISHSRC/include/vrt.h], - [], - [AC_MSG_FAILURE([\$VARNISHSRC "$VARNISHSRC" is not a Varnish source directory])] + [], + [AC_MSG_FAILURE([\$VARNISHSRC "$VARNISHSRC" is not a Varnish source directory])] ) VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)" AC_SUBST(VMOD_TESTS) -PKG_CHECK_VAR([LIBVARNISHAPI_LIBDIR], [varnishapi], [libdir]) -AC_SUBST([VARNISH_LIBRARY_PATH], - [$LIBVARNISHAPI_LIBDIR:$LIBVARNISHAPI_LIBDIR/varnish]) - AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index 4c4051e..9f35d13 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS @@ -14,20 +14,24 @@ # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) +# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is +# needed for multi-threaded programs (defaults to the value of CC +# respectively CXX otherwise). (This is necessary on e.g. AIX to use the +# special cc_r/CC_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" +# CXX="$PTHREAD_CXX" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to @@ -55,6 +59,7 @@ # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. +# Copyright (c) 2019 Marc Stevens # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -67,7 +72,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -82,7 +87,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 23 +#serial 31 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -104,6 +109,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) @@ -123,10 +129,12 @@ fi # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. +# Create a list of thread flags to try. Items with a "," contain both +# C compiler flags (before ",") and linker flags (after ","). Other items +# starting with a "-" are C compiler flags, and remaining items are +# library names, except for "none" which indicates that we try without +# any flags at all, and "pthread-config" which is a program returning +# the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" @@ -194,14 +202,47 @@ case $host_os in # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ;; esac +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + + # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) +# Note that for GCC and Clang -pthread generally implies -lpthread, +# except when -nostdlib is passed. +# This is problematic using libtool to build C++ shared libraries with pthread: +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 +# To solve this, first try -pthread together with -lpthread for GCC + AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) + +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + +AS_IF([test "x$ax_pthread_clang" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread"]) + # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is @@ -224,25 +265,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) -# Are we compiling with Clang? -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + *,*) + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void *some_global = NULL; + static void routine(void *a) + { + /* To avoid any unused-parameter or + unused-but-set-parameter warning. */ + some_global = a; + } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi -ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way @@ -261,11 +363,6 @@ if test "x$ax_pthread_clang" = "xyes"; then # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) - PTHREAD_CFLAGS="-pthread" - PTHREAD_LIBS= - - ax_pthread_ok=yes - # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused @@ -294,7 +391,7 @@ if test "x$ax_pthread_clang" = "xyes"; then # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do @@ -320,78 +417,7 @@ if test "x$ax_pthread_clang" = "xyes"; then fi # $ax_pthread_clang = yes -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -mt,pthread) - AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) - PTHREAD_CFLAGS="-mt" - PTHREAD_LIBS="-lpthread" - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then @@ -438,7 +464,8 @@ if test "x$ax_pthread_ok" = "xyes"; then AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int i = PTHREAD_PRIO_INHERIT;]])], + [[int i = PTHREAD_PRIO_INHERIT; + return i;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) @@ -460,18 +487,28 @@ if test "x$ax_pthread_ok" = "xyes"; then [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], - [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], - [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + [ + AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) + AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) + ], + [ + AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) + AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) + ] + ) + ]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" +test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) +AC_SUBST([PTHREAD_CXX]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then diff --git a/src/Makefile.am b/src/Makefile.am index 84c4f6a..82f8a5a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,7 +6,7 @@ AM_CFLAGS = $(VARNISHAPI_CFLAGS) -Wall -Werror \ -I/usr/include/apr-1.0 \ -I$(VARNISHSRC) -AM_LDFLAGS = $(VARNISHAPI_LIBS) $(VMOD_LDFLAGS) \ +AM_LDFLAGS = $(VMOD_LDFLAGS) \ -lxml2 \ -lapr-1 diff --git a/src/vmod_soap.c b/src/vmod_soap.c index 21a4015..c6ad596 100644 --- a/src/vmod_soap.c +++ b/src/vmod_soap.c @@ -25,11 +25,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + +#include "cache/cache.h" #include "vmod_soap.h" +#include "vcc_soap_if.h" #define POOL_KEY "VRN_IH_PK" -static pthread_mutex_t soap_mutex = PTHREAD_MUTEX_INITIALIZER; static int refcount = 0; static apr_pool_t *apr_pool = NULL; @@ -61,11 +64,12 @@ static void clean_apr() /* -------------------------------------------------------------------------------------/ init vcl */ -static void clean_vcl(void *priv) +static void clean_vcl(VRT_CTX, void *priv) { struct priv_soap_vcl *priv_soap_vcl; struct soap_namespace *ns, *ns2; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CAST_OBJ_NOTNULL(priv_soap_vcl, priv, PRIV_SOAP_VCL_MAGIC); VSLIST_FOREACH_SAFE(ns, &priv_soap_vcl->namespaces, list, ns2) { @@ -114,11 +118,11 @@ static struct priv_soap_task* init_task(VRT_CTX) /* -----------------------------------------------------------------/ destroy session */ -static void clean_task(void *priv) +static void clean_task(VRT_CTX, void *priv) { struct priv_soap_task *soap_task; - AN(priv); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CAST_OBJ_NOTNULL(soap_task, priv, PRIV_SOAP_TASK_MAGIC); clean_req_xml(soap_task->req_xml); @@ -224,13 +228,20 @@ int process_request(struct priv_soap_task *task, enum soap_state state) return (0); } +static const struct vmod_priv_methods priv_soap_vcl_methods[1] = {{ + .magic = VMOD_PRIV_METHODS_MAGIC, + .type = "soap priv_vcl", + .fini = clean_vcl +}}; + /* * handle vmod internal state, vmod init/fini and/or varnish callback * (un)registration here. * */ -int __match_proto__(vmod_event_f) - event_function(VRT_CTX, struct vmod_priv *priv /* PRIV_VCL */, enum vcl_event_e e) +int v_matchproto_(vmod_event_f) + VPFX(event_function)(VRT_CTX, struct vmod_priv *priv /* PRIV_VCL */, + enum vcl_event_e e) { struct priv_soap_vcl *priv_soap_vcl; @@ -238,28 +249,24 @@ int __match_proto__(vmod_event_f) switch (e) { case VCL_EVENT_LOAD: - AZ(pthread_mutex_lock(&soap_mutex)); if(0 == refcount++) { init_xml(); init_apr(); } - AZ(pthread_mutex_unlock(&soap_mutex)); priv_soap_vcl = init_vcl(); priv->priv = priv_soap_vcl; - priv->free = clean_vcl; + priv->methods = priv_soap_vcl_methods; break; case VCL_EVENT_WARM: break; case VCL_EVENT_COLD: break; case VCL_EVENT_DISCARD: - AZ(pthread_mutex_lock(&soap_mutex)); if(0 == --refcount) { clean_xml(); clean_apr(); } - AZ(pthread_mutex_unlock(&soap_mutex)); break; default: return (0); @@ -267,6 +274,12 @@ int __match_proto__(vmod_event_f) return (0); } +static const struct vmod_priv_methods priv_soap_task_methods[1] = {{ + .magic = VMOD_PRIV_METHODS_MAGIC, + .type = "soap priv_task", + .fini = clean_task +}}; + sess_record* priv_soap_get(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) { struct priv_soap_task *soap_task; @@ -275,7 +288,7 @@ sess_record* priv_soap_get(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) AN(priv); if(priv->priv == NULL) { priv->priv = init_task(ctx); - priv->free = clean_task; + priv->methods = priv_soap_task_methods; } CAST_OBJ_NOTNULL(soap_task, priv->priv, PRIV_SOAP_TASK_MAGIC); if(soap_task->ctx != ctx) { @@ -290,7 +303,7 @@ sess_record* priv_soap_get(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) return (soap_task); } -VCL_BOOL __match_proto__(td_soap_is_valid) +VCL_BOOL v_matchproto_(td_soap_is_valid) vmod_is_valid(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) { struct priv_soap_task *soap_task = priv_soap_get(ctx, priv); @@ -298,7 +311,7 @@ VCL_BOOL __match_proto__(td_soap_is_valid) return (process_request(soap_task, ACTION_AVAILABLE) == 0); } -VCL_STRING __match_proto__(td_soap_action) +VCL_STRING v_matchproto_(td_soap_action) vmod_action(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) { struct priv_soap_task *soap_task = priv_soap_get(ctx, priv); @@ -308,7 +321,7 @@ VCL_STRING __match_proto__(td_soap_action) return (""); } -VCL_STRING __match_proto__(td_soap_action_namespace) +VCL_STRING v_matchproto_(td_soap_action_namespace) vmod_action_namespace(VRT_CTX, struct vmod_priv *priv /* PRIV_TASK */) { struct priv_soap_task *soap_task = priv_soap_get(ctx, priv); @@ -318,7 +331,7 @@ VCL_STRING __match_proto__(td_soap_action_namespace) return (""); } -VCL_VOID __match_proto__(td_soap_add_namespace) +VCL_VOID v_matchproto_(td_soap_add_namespace) vmod_add_namespace(VRT_CTX, struct vmod_priv *priv /* PRIV_VCL */, VCL_STRING prefix, VCL_STRING uri) { struct priv_soap_vcl *priv_soap_vcl; @@ -334,7 +347,7 @@ VCL_VOID __match_proto__(td_soap_add_namespace) VSLIST_INSERT_HEAD(&priv_soap_vcl->namespaces, namespace, list); } -VCL_STRING __match_proto__(td_soap_xpath_header) +VCL_STRING v_matchproto_(td_soap_xpath_header) vmod_xpath_header(VRT_CTX, struct vmod_priv *priv_vcl /* PRIV_VCL */, struct vmod_priv *priv_task /* PRIV_TASK */, VCL_STRING xpath) { struct priv_soap_vcl *soap_vcl;; @@ -352,7 +365,7 @@ VCL_STRING __match_proto__(td_soap_xpath_header) return (""); } -VCL_STRING __match_proto__(td_soap_xpath_body) +VCL_STRING v_matchproto_(td_soap_xpath_body) vmod_xpath_body(VRT_CTX, struct vmod_priv *priv_vcl /* PRIV_VCL */, struct vmod_priv *priv_task /* PRIV_TASK */, VCL_STRING xpath) { struct priv_soap_vcl *soap_vcl;; @@ -370,7 +383,7 @@ VCL_STRING __match_proto__(td_soap_xpath_body) return (""); } -VCL_VOID __match_proto__(td_soap_synthetic) +VCL_VOID v_matchproto_(td_soap_synthetic) vmod_synthetic(VRT_CTX, struct vmod_priv *priv_task /* PRIV_TASK */, VCL_INT soap_code, VCL_STRING soap_message) { struct priv_soap_task *soap_task; diff --git a/src/vmod_soap.h b/src/vmod_soap.h index e30cb46..139ca67 100644 --- a/src/vmod_soap.h +++ b/src/vmod_soap.h @@ -28,16 +28,6 @@ #ifndef __VMOD_SOAP__H__ #define __VMOD_SOAP__H__ -/* need vcl.h before vrt.h for vmod_evet_f typedef */ -#include "vcl.h" -#include "vrt.h" -#include "cache/cache.h" -#include "cache/cache_director.h" -#include "cache/cache_backend.h" -#include "vtim.h" -#include "vcc_soap_if.h" -#include - #include #include #include diff --git a/src/vmod_soap_gzip.c b/src/vmod_soap_gzip.c index 013f946..cdf91f1 100644 --- a/src/vmod_soap_gzip.c +++ b/src/vmod_soap_gzip.c @@ -25,10 +25,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + +#include "cache/cache.h" #include "vmod_soap.h" +#include "vcc_soap_if.h" + #include "vmod_soap_http.h" #include "vmod_soap_gzip.h" +// XXX this should be replaced by a vmod parameter +#include "common/common_param.h" +extern volatile struct params * cache_param; + /* ------------------------------------------------------/ Init HTTP context with encoding type */ @@ -65,7 +74,7 @@ void clean_gzip(struct soap_req_http *req_http) */ int uncompress_body_part(struct soap_req_http *req_http, body_part *compressed_body_part, body_part *uncompressed_body_part) { - char *init; + intptr_t init; z_stream *stream; char *buf; Bytef *res_buf = 0; diff --git a/src/vmod_soap_request.c b/src/vmod_soap_request.c index b430cec..b98e7f4 100644 --- a/src/vmod_soap_request.c +++ b/src/vmod_soap_request.c @@ -25,7 +25,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + +// XXX for struct http_conn, should be replaced with buffered body +#include "cache/cache_varnishd.h" #include "vmod_soap.h" +#include "vcc_soap_if.h" + #include "vmod_soap_xml.h" #include "vmod_soap_gzip.h" @@ -63,7 +69,7 @@ fill_pipeline(struct soap_req_http *req_http, struct http_conn *htc, body_part * htc->pipeline_b = buf; htc->pipeline_e = buf + original_pipeline_len; - i = read(htc->fd, htc->pipeline_e, bytes_left); + i = read(*htc->rfd, htc->pipeline_e, bytes_left); if (i <= 0) { if (htc->pipeline_b == htc->pipeline_e) { htc->pipeline_b = NULL; @@ -72,7 +78,7 @@ fill_pipeline(struct soap_req_http *req_http, struct http_conn *htc, body_part * // XXX: VTCP_Assert(i); // but also: EAGAIN VSLb(req_http->ctx->vsl, SLT_FetchError, "%s", strerror(errno)); - req_http->ctx->req->req_body_status = REQ_BODY_FAIL; + req_http->ctx->req->req_body_status = BS_ERROR; return (i); } pipeline->data = htc->pipeline_b + bytes_read; diff --git a/src/vmod_soap_xml.c b/src/vmod_soap_xml.c index 6b63f0b..2d584d0 100644 --- a/src/vmod_soap_xml.c +++ b/src/vmod_soap_xml.c @@ -25,7 +25,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" + +#include "cache/cache.h" #include "vmod_soap.h" +#include "vcc_soap_if.h" + #include "vmod_soap_xml.h" #include "vmod_soap_http.h" #include "vmod_soap_request.h" @@ -109,7 +114,7 @@ const char* evaluate_xpath(struct priv_soap_vcl *soap_vcl, struct priv_soap_task if( xpathObj->nodesetval->nodeTab[i]->children && xpathObj->nodesetval->nodeTab[i]->children->content ) { // Save free pointer to reset workspace in case of overflow - void *f = soap_task->ctx->ws->f; + intptr_t f = WS_Snapshot(soap_task->ctx->ws); char *res = WS_Copy(soap_task->ctx->ws, xpathObj->nodesetval->nodeTab[i]->children->content, -1); xmlXPathFreeContext(xpathCtx); xmlXPathFreeObject(xpathObj); @@ -324,11 +329,9 @@ void synth_soap_fault(struct soap_req_xml *req_xml, int code, const char* messag doc = xmlNewDoc(XMLSTR("1.0")); create_soap_fault(doc, req_xml->error_info); xmlDocDumpMemory(doc, &content, &length); - VRT_synth_page(req_xml->ctx, (const char*)content, vrt_magic_string_end); + VRT_synth_page(req_xml->ctx, TOSTRAND((const char*)content)); VRT_SetHdr(req_xml->ctx, &VGC_HDR_RESP_Content_2d_Type, - "application/soap+xml; charset=utf-8", - vrt_magic_string_end - ); + "application/soap+xml; charset=utf-8", NULL); xmlFree(content); xmlFreeDoc(doc); }