Unverified Commit 5af25b48 authored by Geoff Simmons's avatar Geoff Simmons Committed by Nils Goroll

Initial public release

parents
((nil . ((indent-tabs-mode . t)))
(c-mode . ((c-file-style . "BSD"))))
Makefile
Makefile.in
.deps/
.libs/
*.o
*.lo
*.la
*~
*.[1-9]
*.gcda
*.gcno
.dirstamp
/aclocal.m4
/ar-lib
/autom4te.cache/
/compile
/config.guess
/config.h
/config.h.in
/config.log
/config.status
/config.sub
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/missing
/stamp-h1
/test-driver
/m4/
/src/vcc_pesi_debug_if.[ch]
/src/vcc_pesi_if.[ch]
/src/vmod_*rst
/src/VSC_pesi.c
/src/VSC_pesi.h
/src/tests/*.log
/src/tests/*.trs
/src/test-suite.log
/src/coverage
CONTRIBUTING
============
To contribute code or documentation, submit a pull request at the
`source repository website
<https://gitlab.com/uplex/varnish/libvdp-pesi>`_.
If you have a problem or discover a bug, you can post an `issue
<https://gitlab.com/uplex/varnish/libvdp-pesi/issues>`_ at
the website. You can also write to <varnish-support@uplex.de>.
For developers
--------------
The VDP depends heavily on function calls that are internal to
Varnish, and are not part of the public APIs provided for VMODs and
delivery or fetch processors. This is why the build requires a Varnish
source tree, identified with the ``VARNISHSRC`` variable in the
invocation of ``configure``, as described in `INSTALL.rst
<INSTALL.rst>`_. Some of the function and struct definitions that are
declared static in the Varnish source are copied in the
``src/foreign`` directory of the VDP source.
Elements of the Varnish code that are not public may be changed
without notice in future versions. In that case, the VDP code will
have to be updated as the need arises.
The VDP source code is in C, and compilation has been tested with gcc
and clang. The code MUST always compile successfully with both of
them.
The build specifies C99 conformance for C sources (``-std=c99``). All
compiler warnings are turned on, and all warnings are considered
errors (``-Werror -Wall -Wextra``). The code MUST always build
without warnings or errors under these constraints.
By default, ``CFLAGS`` is set to ``-g -O2``, so that symbols are
included in the shared library, and optimization is at level
``O2``. To change or disable these options, set ``CFLAGS`` explicitly
before calling ``configure`` (it may be set to the empty string).
For development/debugging cycles, the ``configure`` option
``--enable-debugging`` is recommended (off by default). This will turn
off optimizations and function inlining, so that a debugger will step
through the code as expected.
Experience has shown that adding ``-ggdb3`` to ``CFLAGS`` is
beneficial if you need to examine the VDP with the gdb debugger. The
shared object for a VDP (as for VMODs) is loaded from a directory
relative to the Varnish home directory (by default
``/usr/local/var/$INSTANCE`` for development builds). A debugger needs
to locate the shared object from that relative path to load its
symbols, so the Varnish home directory should be the current working
directory when the debugger is run. For example::
# To run gdb and examine a coredump
$ cd /usr/local/var/myinstance
$ gdb /usr/local/sbin/varnishd /path/to/coredump
By default, the VDP is built with the stack protector enabled
(compile option ``-fstack-protector``), but it can be disabled with
the ``configure`` option ``--disable-stack-protector``.
See LICENSE for details.
INSTALLATION
============
RPMs
~~~~
Binary, debuginfo and source RPMs for the VDP are available at:
https://pkg.uplex.de/
The packages are built for Enterprise Linux 7 (el7), and hence will
run on compatible distros (such as RHEL7, Fedora, CentOS 7 and Amazon
Linux).
To add the repo to your YUM configuration::
yum-config-manager --add-repo https://pkg.uplex.de/rpm/7/uplex-varnish/x86_64/
The RPM for the VDP requires a Varnish installation from the official
packages:
https://packagecloud.io/varnishcache
You can then install the VDP with::
yum install --nogpgcheck vdp-pesi
If you have problems or questions concerning the RPMs, post an issue
to the source repository web site for the VDP, or contact
<varnish-support@uplex.de>.
Building from source
~~~~~~~~~~~~~~~~~~~~
The VDP is built against both a Varnish development installation *and*
a Varnish source tree. The Varnish source tree must be built, so that
generated sources are present; that is, its build process must be
carried out at least as far the execution of ``make``. The build
version of installed Varnish must match the version of the source
tree; this means that the "commit ID" portion of the version string of
installed Varnish must match the HEAD of the source tree. A simple
solution is to build and install Varnish from the source tree. If
Varnish is installed by other means (for example from package), then
the commit IDs must match.
For the installation, the autotools use ``pkg-config(1)`` to locate
the necessary header files and other resources for Varnish. The root
directory of the source tree is identified by the variable
``VARNISHSRC`` in the invocation of ``configure``.
This sequence will install the VDP::
> ./autogen.sh # for builds from the git repo
> ./configure VARNISHSRC=/path/to/source/tree
> make
> make check # to run unit tests in src/tests/*.vtc
> make distcheck # run check and prepare a distribution tarball
> sudo make install
See `CONTRIBUTING.rst <CONTRIBUTING.rst>`_ for notes about building
from source.
If you have installed Varnish in non-standard directories, call
``autogen.sh`` and ``configure`` with the ``PKG_CONFIG_PATH``
environment variable set to include the paths where the ``.pc`` file
can be located for ``varnishapi``. For example, when varnishd
configure was called with ``--prefix=$PREFIX``, use::
> PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
> export PKG_CONFIG_PATH
By default, the ``configure`` script installs the VDP in the VMOD
directory for Varnish, determined via ``pkg-config(1)``. The VMOD
installation directory can be overridden by passing the ``VMOD_DIR``
variable to ``configure``.
Other files such as the man-page are installed in the locations
determined by ``configure``, which inherits its default ``--prefix``
setting from Varnish.
Copyright 2019 - 2021 UPLEX Nils Goroll Systemoptimierung
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
ACLOCAL_AMFLAGS = -I m4 -I ${VARNISHAPI_DATAROOTDIR}/aclocal
SUBDIRS = src
DISTCHECK_CONFIGURE_FLAGS = \
VMOD_DIR='$${libdir}/varnish/vmods'
EXTRA_DIST = README.rst LICENSE COPYING CONTRIBUTING.rst INSTALL.rst
doc_DATA = README.rst LICENSE COPYING CONTRIBUTING.rst INSTALL.rst
README.rst: src/vdp_pesi.vcc
$(MAKE) $(AM_MAKEFLAGS) -C src vmod_pesi.man.rst
cp src/vmod_pesi.man.rst README.rst
coverage:
$(MAKE) $(AM_MAKEFLAGS) -C src coverage
%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9:
if HAVE_RST2MAN
${RST2MAN} $< $@
else
@echo "========================================"
@echo "You need rst2man installed to make dist"
@echo "========================================"
@false
endif
This diff is collapsed.
#!/bin/sh
warn() {
echo "WARNING: $@" 1>&2
}
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
;;
FreeBSD)
LIBTOOLIZE=libtoolize
;;
Linux)
LIBTOOLIZE=libtoolize
;;
SunOS)
LIBTOOLIZE=libtoolize
;;
*)
warn "unrecognized platform:" `uname -s`
LIBTOOLIZE=libtoolize
esac
automake_version=`automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+'`
if [ -z "$automake_version" ] ; then
warn "unable to determine automake version"
else
case $automake_version in
0.*|1.[0-8]|1.[0-8][.-]*)
warn "automake ($automake_version) detected; 1.9 or newer recommended"
;;
*)
;;
esac
fi
# check for varnishapi.m4 in custom paths
dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
if [ -z "$dataroot" ] ; then
cat >&2 <<'EOF'
Package varnishapi was not found in the pkg-config search path.
Perhaps you should add the directory containing `varnishapi.pc'
to the PKG_CONFIG_PATH environment variable
EOF
exit 1
fi
set -ex
aclocal -I m4 -I ${dataroot}/aclocal
$LIBTOOLIZE --copy --force
autoheader
automake --add-missing --copy --foreign
autoconf
AC_PREREQ(2.68)
AC_COPYRIGHT([Copyright 2019 - 2021 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([libvdp-pesi], [trunk], [varnish-support@uplex.de], [vdp-pesi])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vdp_pesi.vcc)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AC_LANG(C)
AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
AM_SILENT_RULES([yes])
AM_PROG_AR
LT_PREREQ([2.2.6])
LT_INIT([dlopen disable-static])
AC_PROG_CC
AC_PROG_CC_STDC
if test "x$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([Could not find a C99 compatible compiler])
fi
AC_PROG_CPP
AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
AC_ARG_WITH([rst2man],
AS_HELP_STRING(
[--with-rst2man=PATH],
[Location of rst2man (auto)]),
[RST2MAN="$withval"],
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], []))
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
AC_ARG_WITH([lcov],
AS_HELP_STRING(
[--with-lcov=PATH],
[Location of lcov to generate coverage data (auto)]),
[LCOV="$withval"],
AC_CHECK_PROGS(LCOV, [lcov], []))
AM_CONDITIONAL(HAVE_LCOV, [test -n "$LCOV"])
AC_ARG_WITH([genhtml],
AS_HELP_STRING(
[--with-genhtml=PATH],
[Location of genhtml to generate coverage reports (auto)]),
[GENHTML="$withval"],
AC_CHECK_PROGS(GENHTML, [genhtml], []))
AM_CONDITIONAL(HAVE_GENHTML, [test -n "$GENHTML"])
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([trunk])
VARNISH_VMODS([pesi pesi_debug])
VARNISH_COUNTERS([pesi])
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])
# Checks for C functions
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([strchr])
# C headers
AC_CHECK_HEADERS([limits.h])
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADER_STDBOOL
# C types
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_INLINE
AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (REQUIRED)])
if test "${VARNISHSRC+set}" != set; then
AC_MSG_ERROR([VARNISHSRC must be set (path to Varnish source tree)])
fi
AC_CHECK_FILE(["$VARNISHSRC/include/miniobj.h"],
[AC_MSG_RESULT([VARNISHSRC (Varnish source dir)... $VARNISHSRC])],
[AC_MSG_ERROR([VARNISHSRC ($VARNISHSRC) is not a Varnish source dir])])
# --enable-stack-protector
AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]),
[],
[enable_stack_protector=yes])
if test "x$enable_stack_protector" != "xno"; then
AX_CHECK_COMPILE_FLAG([-fstack-protector],
AX_CHECK_LINK_FLAG([-fstack-protector],
[CFLAGS="${CFLAGS} -fstack-protector"], [], []),
[], [])
fi
# --enable-debugging
AC_ARG_ENABLE(debugging,
AS_HELP_STRING([--enable-debugging],[enable debugging (default is NO)]),
[],
[enable_debugging=no])
# AC_PROG_CC sets CFLAGS to '-g -O2' unless already set, so there's no
# need to add -g. Disable or change by explicitly setting CFLAGS. If
# this option is enabled, then -Og or -O0 becomes the last
# optimization option, and hence takes precedence.
if test "x$enable_debugging" != "xno"; then
CFLAGS="${CFLAGS} -fno-inline"
AX_CHECK_COMPILE_FLAG([-Og],
[CFLAGS="${CFLAGS} -O0 -Og"],
[CFLAGS="${CFLAGS} -O0"],
[])
fi
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT
AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS = $(VARNISHAPI_CFLAGS) -I$(VARNISHSRC)/include \
-I$(VARNISHSRC)/bin/varnishd -I$(VARNISHSRC)/lib/libvgz \
-Wall -Werror -Wextra -std=c99
AM_LDFLAGS = $(VARNISHAPI_LIBS) $(VMOD_LDFLAGS) -ldl
vmod_LTLIBRARIES = libvmod_pesi.la libvmod_pesi_debug.la
libvmod_pesi_la_SOURCES = \
misc.h \
misc.c \
pesi.h \
pesi_flags.h \
pesi_tree.h \
pesi.c \
node.h \
node_assert.h \
node_head.h \
node_mempool.h \
node.c \
vmod_pesi.c \
vdp_pesi.h \
vdp_pesi.c \
debug.h \
tbl_set_parameter.h \
foreign/qdef.h \
foreign/from_cache_esi_deliver.h \
foreign/from_cache_esi_deliver.c
nodist_libvmod_pesi_la_SOURCES = \
vcc_pesi_if.c \
vcc_pesi_if.h \
VSC_pesi.c \
VSC_pesi.h
libvmod_pesi_debug_la_SOURCES = \
vmod_pesi_debug.c
nodist_libvmod_pesi_debug_la_SOURCES = \
vcc_pesi_debug_if.c \
vcc_pesi_debug_if.h
dist_man_MANS = vdp_pesi.3
@BUILD_VSC_PESI@
# -- pesi
vmod_pesi.lo: vcc_pesi_if.h VSC_pesi.c VSC_pesi.h misc.h node_mempool.h \
pesi_flags.h vdp_pesi.h tbl_set_parameter.h
vdp_pesi.lo: debug.h vdp_pesi.h node.h node_assert.h pesi.h pesi_flags.h \
pesi_tree.h misc.h
misc.lo: misc.h debug.h
node.lo: debug.h node.h node_assert.h node_mempool.h pesi.h misc.h vcc_pesi_if.h
pesi.lo: debug.h VSC_pesi.h pesi_tree.h pesi_flags.h pesi.h
vcc_pesi_if.h vmod_pesi.rst vmod_pesi.man.rst: vcc_pesi_if.c
vcc_pesi_if.c: vdp_pesi.vcc
$(AM_V_VMODTOOL) $(PYTHON) $(VMODTOOL) -o vcc_pesi_if $(srcdir)/vdp_pesi.vcc
vdp_pesi.3: vmod_pesi.man.rst
$(AM_V_GEN) $(RST2MAN) vmod_pesi.man.rst vdp_pesi.3
# -- pesi_debug
vcc_pesi_debug_if.h vmod_pesi_debug.rst vmod_pesi_debug.man.rst: vcc_pesi_debug_if.c
vcc_pesi_debug_if.c: vmod_pesi_debug.vcc
$(AM_V_VMODTOOL) $(PYTHON) $(VMODTOOL) -o vcc_pesi_debug_if $(srcdir)/vmod_pesi_debug.vcc
AM_TESTS_ENVIRONMENT = \
PATH="$(VMOD_TEST_PATH)" \
LD_LIBRARY_PATH="$(VARNISH_LIBRARY_PATH)"
TEST_EXTENSIONS = .vtc
TESTFLAGS = -v -t 20
VTC_LOG_COMPILER = varnishtest ${TESTFLAGS}
AM_VTC_LOG_FLAGS = -Dvmod_pesi="$(VMOD_PESI)" \
-Dvmod_pesi_debug="$(VMOD_PESI_DEBUG)" \
-p vcl_path=$(abs_srcdir)/tests
# To test an individual VTC test named test.vtc:
# $ make check TESTS=tests/test.vtc
TESTS = @VMOD_TESTS@
gcov: clean
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) CC=gcc \
CFLAGS="${AM_CFLAGS} --coverage -fno-inline -g -O0" check
# Set QUIET=-q for non-verbose builds, otherwise set to empty.
QUIET_0 = -q
QUIET_ = $(QUIET_@AM_DEFAULT_V@)
QUIET = $(QUIET_@AM_V@)
coverage/lcov.info: gcov
if HAVE_LCOV
$(AM_V_at)@mkdir $(builddir)/coverage
$(AM_V_GEN) $(LCOV) $(QUIET) -c -d . -o $(builddir)/coverage/lcov.info
else
@echo "================================================="
@echo "You need lcov installed to generate coverage data"
@echo "================================================="
@false
endif
coverage: coverage/lcov.info
if HAVE_GENHTML
$(AM_V_GEN) $(GENHTML) $(QUIET) $(builddir)/coverage/lcov.info \
-o $(builddir)/coverage
else
@echo "======================================================="
@echo "You need genhtml installed to generate coverage reports"
@echo "======================================================="
@false
endif
EXTRA_DIST = \
vdp_pesi.vcc \
vmod_pesi_debug.vcc \
pesi.vsc \
$(VMOD_TESTS) \
$(builddir)/tests/debug.inc.vcl
CLEANFILES = \
$(builddir)/vcc_pesi_if.c \
$(builddir)/vcc_pesi_if.h \
$(builddir)/vmod_pesi.rst \
$(builddir)/vmod_pesi.man.rst \
$(builddir)/vcc_pesi_debug_if.c \
$(builddir)/vcc_pesi_debug_if.h \
$(builddir)/vmod_pesi_debug.rst \
$(builddir)/vmod_pesi_debug.man.rst \
$(builddir)/vdp_pesi.3 \
$(builddir)/VSC_pesi.c \
$(builddir)/VSC_pesi.h \
$(builddir)/*.gcda \
$(builddir)/*.gcno
clean-local:
@rm -rf $(builddir)/coverage
#ifdef DEBUG
#include <stdio.h>
#include "vtim.h"
#define Debug(fmt, ...) printf(fmt, __VA_ARGS__)
#define VSLdbgv(tng, fmt, ...) \
do { \
VSL(SLT_Debug, 0, "xid=%u t=%.6f " fmt, \
VXID((tng)->vsl->wid), VTIM_real(), __VA_ARGS__); \
VSLb((tng)->vsl, SLT_Debug, fmt, __VA_ARGS__); \
} while(0)
#define VSLdbg(tng, msg) \
do { \
VSL(SLT_Debug, 0, "xid=%u t=%.6f " msg, \
VXID((tng)->vsl->wid), VTIM_real()); \
VSLb((tng)->vsl, SLT_Debug, msg); \
} while(0)
#define VSL0dbg(...) VSL(SLT_Debug, 0, __VA_ARGS__)
#else
#define VSLdbgv(tng, fmt, ...) (void)0
#define VSLdbg(tng, msg) (void)0
#define VSL0dbg(...) (void)0
#define Debug(fmt, ...) /**/
#endif
-emacro(655, OC_F_FINAL)
-efile(766, "../config.h")
// we do not lint the VSC files
-esym(526, VSC_pesi_New, VSC_pesi_Destroy)
-esym(755, VSC_pesi_size)
-esym(769, *INVALID)
\ No newline at end of file
#!/bin/sh
if [ "x$1" = "x-ok" -a -f _.fl ] ; then
echo "Saved as reference"
mv _.fl _.fl.old
exit 0
fi
flexelint \
-D__FLEXELINT__ \
${VARNISHSRC}/flint.lnt \
flint.lnt \
-zero \
-I.. \
-I${VARNISHSRC}/include \
-I${VARNISHSRC}/bin/varnishd \
-I${VARNISHSRC}/lib/libvgz \
$(ls *.c | grep -v VSC_) \
foreign/*.c \
2>&1 | tee _.fl
if [ -f _.fl.old ] ; then
diff -u _.fl.old _.fl
fi
if [ "x$1" = "x-ok" ] ; then
echo "Saved as reference"
mv _.fl _.fl.old
fi
/*-
* Copyright (c) 2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* VPED - Varnish Parallel Esi Delivery
*
* modded version for parallel PESI
*
* actual esi handling is in vdp_pesi.c, this file contains VDPs we keep
* functionally equivalent to varnish-cache built-in esi, just with changed
* signatures & data structures
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "cache/cache.h"
#include "cache/cache_filter.h"
//#include "vtim.h"
//#include "cache_esi.h"
#include "vend.h"
#include "vgz.h"
#include "from_cache_esi_deliver.h"
/*---------------------------------------------------------------------
* If a gzip'ed ESI object includes a ungzip'ed object, we need to make
* it looked like a gzip'ed data stream. The official way to do so would
* be to fire up libvgz and gzip it, but we don't, we fake it.
*
* First, we cannot know if it is ungzip'ed on purpose, the admin may
* know something we don't.
*
* What do you mean "BS ?"
*
* All right then...
*
* The matter of the fact is that we simply will not fire up a gzip in
* the output path because it costs too much memory and CPU, so we simply
* wrap the data in very convenient "gzip copy-blocks" and send it down
* the stream with a bit more overhead.
*/
static int v_matchproto_(vdp_fini_f)
vped_pretend_gzip_fini(struct vdp_ctx *vdc, void **priv)
{
(void)vdc;
*priv = NULL;
return (0);
}
static int v_matchproto_(vdp_bytes_f)
vped_pretend_gzip_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
const void *pv, ssize_t l)
{
uint8_t buf1[5], buf2[5];
const uint8_t *p;
uint16_t lx;
struct nexus_gzip *gz;
CHECK_OBJ_NOTNULL(vdx, VDP_CTX_MAGIC);
CAST_OBJ_NOTNULL(gz, *priv, NEXUS_GZIP_MAGIC);
if (l == 0)
return (VDP_bytes(vdx, act, pv, l));
p = pv;
AN (gz->is);