From tfheen at varnish-cache.org Mon Jul 1 12:28:36 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 01 Jul 2013 14:28:36 +0200 Subject: [master] 88039bb Use the right attribute for __unused with gcc Message-ID: commit 88039bb36f792cc89a76453040b09d6fe104f707 Author: Tollef Fog Heen Date: Mon Jul 1 14:28:05 2013 +0200 Use the right attribute for __unused with gcc diff --git a/include/vdef.h b/include/vdef.h index 89694b2..2a0addb 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -67,6 +67,14 @@ # endif #endif +#ifndef __unused +# if __GNUC_PREREQ(2, 95) || defined(__INTEL_COMPILER) +# define __unused __attribute__((__unused__)) +# else +# define __unused +# endif +#endif + /********************************************************************** * FlexeLint and compiler shutuppery */ From tfheen at varnish-cache.org Mon Jul 1 12:28:36 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 01 Jul 2013 14:28:36 +0200 Subject: [master] dd0a14f Fix up curses detection logic, Solaris fixes Message-ID: commit dd0a14fcad95cd107980499f64128df4990f38e5 Author: Tollef Fog Heen Date: Fri Jun 14 09:12:09 2013 +0200 Fix up curses detection logic, Solaris fixes Makes git master compile on Solaris again, and mostly work. diff --git a/bin/Makefile.am b/bin/Makefile.am index 02bfe66..0700f27 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -5,7 +5,7 @@ #SUBDIRS = varnishadm varnishd varnishlog varnishncsa varnishreplay varnishtest SUBDIRS = varnishadm varnishd varnishlog varnishtest -if HAVE_CURSES +if VARNISH_CURSES #SUBDIRS += varnishhist varnishstat varnishtop SUBDIRS += varnishstat endif diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 91719e8..5423155 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -14,7 +14,7 @@ varnishhist_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ -lm \ - ${CURSES_LIBS} ${RT_LIBS} ${PTHREAD_LIBS} + @CURSES_LIB@ ${RT_LIBS} ${PTHREAD_LIBS} varnishhist.1: $(top_srcdir)/doc/sphinx/reference/varnishhist.rst if HAVE_RST2MAN diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 6060438..d22edac 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -18,7 +18,7 @@ varnishstat_SOURCES = \ varnishstat_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ - ${CURSES_LIBS} ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} + @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} varnishstat.1: $(top_srcdir)/doc/sphinx/reference/varnishstat.rst if HAVE_RST2MAN diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 6fc7c8a..16df1b4 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -54,12 +54,18 @@ #include "varnishstat.h" -#ifdef HAVE_NCURSES_CURSES_H +#if defined HAVE_NCURSESW_CURSES_H +# include +#elif defined HAVE_NCURSESW_H +# include +#elif defined HAVE_NCURSES_CURSES_H # include +#elif defined HAVE_NCURSES_H +# include +#elif defined HAVE_CURSES_H +# include #else -# ifdef HAVE_CURSES_H -# include -# endif +# error "SysV or X/Open-compatible Curses header file required" #endif #define LINES_STATUS 3 @@ -892,10 +898,12 @@ do_curses(struct VSM_data *vd, int delay) switch (ch = wgetch(w_status)) { case ERR: break; +#ifdef KEY_RESIZE /* sigh, Solaris lacks this.. */ case KEY_RESIZE: make_windows(); update_position(); break; +#endif default: handle_keypress(ch); break; diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am index b2f5c89..54e672f 100644 --- a/bin/varnishtop/Makefile.am +++ b/bin/varnishtop/Makefile.am @@ -13,7 +13,7 @@ varnishtop_SOURCES = varnishtop.c \ varnishtop_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ - ${CURSES_LIBS} ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} + @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} varnishtop.1: $(top_srcdir)/doc/sphinx/reference/varnishtop.rst if HAVE_RST2MAN diff --git a/configure.ac b/configure.ac index f2efa37..a43f209 100644 --- a/configure.ac +++ b/configure.ac @@ -84,18 +84,8 @@ DL_LIBS="${LIBS}" LIBS="${save_LIBS}" AC_SUBST(DL_LIBS) -save_LIBS="${LIBS}" -LIBS="" -AC_SEARCH_LIBS(initscr, [curses ncurses], - [have_curses=yes], [have_curses=no]) -CURSES_LIBS="${LIBS}" -LIBS="${save_LIBS}" -AC_SUBST(CURSES_LIBS) -if test "$have_curses" = no; then - AC_MSG_WARN([curses not found; some tools will not be built]) -fi -AC_CHECK_HEADERS([ncurses/curses.h curses.h]) -AM_CONDITIONAL([HAVE_CURSES], [test x$have_curses = xyes]) +AX_WITH_CURSES +AM_CONDITIONAL(VARNISH_CURSES, test x$ax_cv_curses = xyes) save_LIBS="${LIBS}" LIBS="" diff --git a/m4/ax_with_curses.m4 b/m4/ax_with_curses.m4 new file mode 100644 index 0000000..33a37ac --- /dev/null +++ b/m4/ax_with_curses.m4 @@ -0,0 +1,518 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_with_curses.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_CURSES +# +# DESCRIPTION +# +# This macro checks whether a SysV or X/Open-compatible Curses library is +# present, along with the associated header file. The NcursesW +# (wide-character) library is searched for first, followed by Ncurses, +# then the system-default plain Curses. The first library found is the +# one returned. +# +# The following options are understood: --with-ncursesw, --with-ncurses, +# --without-ncursesw, --without-ncurses. The "--with" options force the +# macro to use that particular library, terminating with an error if not +# found. The "--without" options simply skip the check for that library. +# The effect on the search pattern is: +# +# (no options) - NcursesW, Ncurses, Curses +# --with-ncurses --with-ncursesw - NcursesW only [*] +# --without-ncurses --with-ncursesw - NcursesW only [*] +# --with-ncursesw - NcursesW only [*] +# --with-ncurses --without-ncursesw - Ncurses only [*] +# --with-ncurses - NcursesW, Ncurses [**] +# --without-ncurses --without-ncursesw - Curses only +# --without-ncursesw - Ncurses, Curses +# --without-ncurses - NcursesW, Curses +# +# [*] If the library is not found, abort the configure script. +# +# [**] If the second library (Ncurses) is not found, abort configure. +# +# The following preprocessor symbols may be defined by this macro if the +# appropriate conditions are met: +# +# HAVE_CURSES - if any SysV or X/Open Curses library found +# HAVE_CURSES_ENHANCED - if library supports X/Open Enhanced functions +# HAVE_CURSES_COLOR - if library supports color (enhanced functions) +# HAVE_CURSES_OBSOLETE - if library supports certain obsolete features +# HAVE_NCURSESW - if NcursesW (wide char) library is to be used +# HAVE_NCURSES - if the Ncurses library is to be used +# +# HAVE_CURSES_H - if is present and should be used +# HAVE_NCURSESW_H - if should be used +# HAVE_NCURSES_H - if should be used +# HAVE_NCURSESW_CURSES_H - if should be used +# HAVE_NCURSES_CURSES_H - if should be used +# +# (These preprocessor symbols are discussed later in this document.) +# +# The following output variable is defined by this macro; it is precious +# and may be overridden on the ./configure command line: +# +# CURSES_LIB - library to add to xxx_LDADD +# +# The library listed in CURSES_LIB is NOT added to LIBS by default. You +# need to add CURSES_LIB to the appropriate xxx_LDADD line in your +# Makefile.am. For example: +# +# prog_LDADD = @CURSES_LIB@ +# +# If CURSES_LIB is set on the configure command line (such as by running +# "./configure CURSES_LIB=-lmycurses"), then the only header searched for +# is . The user may use the CPPFLAGS precious variable to +# override the standard #include search path. If the user needs to +# specify an alternative path for a library (such as for a non-standard +# NcurseW), the user should use the LDFLAGS variable. +# +# The following shell variables may be defined by this macro: +# +# ax_cv_curses - set to "yes" if any Curses library found +# ax_cv_curses_enhanced - set to "yes" if Enhanced functions present +# ax_cv_curses_color - set to "yes" if color functions present +# ax_cv_curses_obsolete - set to "yes" if obsolete features present +# +# ax_cv_ncursesw - set to "yes" if NcursesW library found +# ax_cv_ncurses - set to "yes" if Ncurses library found +# ax_cv_plaincurses - set to "yes" if plain Curses library found +# ax_cv_curses_which - set to "ncursesw", "ncurses", "plaincurses" or "no" +# +# These variables can be used in your configure.ac to determine the level +# of support you need from the Curses library. For example, if you must +# have either Ncurses or NcursesW, you could include: +# +# AX_WITH_CURSES +# if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then +# AX_MSG_ERROR([requires either NcursesW or Ncurses library]) +# fi +# +# If any Curses library will do (but one must be present and must support +# color), you could use: +# +# AX_WITH_CURSES +# if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then +# AC_MSG_ERROR([requires an X/Open-compatible Curses library with color]) +# fi +# +# Certain preprocessor symbols and shell variables defined by this macro +# can be used to determine various features of the Curses library. In +# particular, HAVE_CURSES and ax_cv_curses are defined if the Curses +# library found conforms to the traditional SysV and/or X/Open Base Curses +# definition. Any working Curses library conforms to this level. +# +# HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the +# library supports the X/Open Enhanced Curses definition. In particular, +# the wide-character types attr_t, cchar_t and wint_t, the functions +# wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES +# are checked. The Ncurses library does NOT conform to this definition, +# although NcursesW does. +# +# HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library +# supports color functions and macros such as COLOR_PAIR, A_COLOR, +# COLOR_WHITE, COLOR_RED and init_pair(). These are NOT part of the +# X/Open Base Curses definition, but are part of the Enhanced set of +# functions. The Ncurses library DOES support these functions, as does +# NcursesW. +# +# HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the +# library supports certain features present in SysV and BSD Curses but not +# defined in the X/Open definition. In particular, the functions +# getattrs(), getcurx() and getmaxx() are checked. +# +# To use the HAVE_xxx_H preprocessor symbols, insert the following into +# your system.h (or equivalent) header file: +# +# #if defined HAVE_NCURSESW_CURSES_H +# # include +# #elif defined HAVE_NCURSESW_H +# # include +# #elif defined HAVE_NCURSES_CURSES_H +# # include +# #elif defined HAVE_NCURSES_H +# # include +# #elif defined HAVE_CURSES_H +# # include +# #else +# # error "SysV or X/Open-compatible Curses header file required" +# #endif +# +# For previous users of this macro: you should not need to change anything +# in your configure.ac or Makefile.am, as the previous (serial 10) +# semantics are still valid. However, you should update your system.h (or +# equivalent) header file to the fragment shown above. You are encouraged +# also to make use of the extended functionality provided by this version +# of AX_WITH_CURSES, as well as in the additional macros +# AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM. +# +# LICENSE +# +# Copyright (c) 2009 Mark Pulford +# Copyright (c) 2009 Damian Pietras +# Copyright (c) 2012 Reuben Thomas +# Copyright (c) 2011 John Zaitseff +# +# 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 +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# 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 +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 13 + +AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES]) +AC_DEFUN([AX_WITH_CURSES], [ + AC_ARG_VAR([CURSES_LIB], [linker library for Curses, e.g. -lcurses]) + AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses], + [force the use of Ncurses or NcursesW])], + [], [with_ncurses=check]) + AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw], + [do not use NcursesW (wide character support)])], + [], [with_ncursesw=check]) + + ax_saved_LIBS=$LIBS + AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes], + [ax_with_plaincurses=no], [ax_with_plaincurses=check]) + + ax_cv_curses_which=no + + # Test for NcursesW + + AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncursesw" != xno], [ + LIBS="$ax_saved_LIBS -lncursesw" + + AC_CACHE_CHECK([for NcursesW wide-character library], [ax_cv_ncursesw], [ + AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])], + [ax_cv_ncursesw=yes], [ax_cv_ncursesw=no]) + ]) + AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [ + AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library]) + ]) + + AS_IF([test "x$ax_cv_ncursesw" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=ncursesw + CURSES_LIB="-lncursesw" + AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncursesw_curses_h=yes], + [ax_cv_header_ncursesw_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncursesw_h=yes], + [ax_cv_header_ncursesw_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSESW_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_header_ncurses_h_with_ncursesw=yes], + [ax_cv_header_ncurses_h_with_ncursesw=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if is present]) + ]) + + AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xno && test "x$ax_cv_header_ncursesw_h" = xno && test "x$ax_cv_header_ncurses_h_with_ncursesw" = xno], [ + AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h]) + ]) + ]) + ]) + + # Test for Ncurses + + AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [ + LIBS="$ax_saved_LIBS -lncurses" + + AC_CACHE_CHECK([for Ncurses library], [ax_cv_ncurses], [ + AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])], + [ax_cv_ncurses=yes], [ax_cv_ncurses=no]) + ]) + AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [ + AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library]) + ]) + + AS_IF([test "x$ax_cv_ncurses" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=ncurses + CURSES_LIB="-lncurses" + AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_header_ncurses_curses_h=yes], + [ax_cv_header_ncurses_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [ + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if is present]) + ]) + + AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_header_ncurses_h=yes], + [ax_cv_header_ncurses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [ + ax_cv_curses_color=yes + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if is present]) + ]) + + AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [ + AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h]) + ]) + ]) + ]) + + # Test for plain Curses (or if CURSES_LIB was set by user) + + AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [ + AS_IF([test "x$CURSES_LIB" != x], [ + LIBS="$ax_saved_LIBS $CURSES_LIB" + ], [ + LIBS="$ax_saved_LIBS -lcurses" + ]) + + AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [ + AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])], + [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no]) + ]) + + AS_IF([test "x$ax_cv_plaincurses" = xyes], [ + ax_cv_curses=yes + ax_cv_curses_which=plaincurses + AS_IF([test "x$CURSES_LIB" = x], [ + CURSES_LIB="-lcurses" + ]) + AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present]) + + # Check for base conformance (and header file) + + AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + initscr(); + ]])], + [ax_cv_header_curses_h=yes], + [ax_cv_header_curses_h=no]) + ]) + AS_IF([test "x$ax_cv_header_curses_h" = xyes], [ + AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if is present]) + + # Check for X/Open Enhanced conformance + + AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + @%:@ifndef _XOPEN_CURSES + @%:@error "this Curses library is not enhanced" + "this Curses library is not enhanced" + @%:@endif + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + attr_t d = WA_NORMAL; + cchar_t e; + wint_t f; + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + wattr_set(stdscr, d, 0, NULL); + wget_wch(stdscr, &f); + ]])], + [ax_cv_plaincurses_enhanced=yes], + [ax_cv_plaincurses_enhanced=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [ + ax_cv_curses_enhanced=yes + ax_cv_curses_color=yes + AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions]) + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + ]) + + # Check for color functions + + AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@define _XOPEN_SOURCE_EXTENDED 1 + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + chtype c = COLOR_PAIR(1) & A_COLOR; + initscr(); + init_pair(1, COLOR_WHITE, COLOR_RED); + ]])], + [ax_cv_plaincurses_color=yes], + [ax_cv_plaincurses_color=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [ + ax_cv_curses_color=yes + AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)]) + ]) + + # Check for obsolete functions + + AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + chtype a = A_BOLD; + int b = KEY_LEFT; + int g = getattrs(stdscr); + int h = getcurx(stdscr) + getmaxx(stdscr); + initscr(); + ]])], + [ax_cv_plaincurses_obsolete=yes], + [ax_cv_plaincurses_obsolete=no]) + ]) + AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [ + ax_cv_curses_obsolete=yes + AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features]) + ]) + ]) + + AS_IF([test "x$ax_cv_header_curses_h" = xno], [ + AC_MSG_WARN([could not find a working curses.h]) + ]) + ]) + ]) + + AS_IF([test "x$ax_cv_curses" != xyes], [ax_cv_curses=no]) + AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no]) + AS_IF([test "x$ax_cv_curses_color" != xyes], [ax_cv_curses_color=no]) + AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no]) + + LIBS=$ax_saved_LIBS +])dnl From tfheen at varnish-cache.org Mon Jul 1 12:28:36 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 01 Jul 2013 14:28:36 +0200 Subject: [master] 8f7e4ec Include vdef.h for __printflike Message-ID: commit 8f7e4ec94f29e74a8ed3cb504e6d4ad1457e945c Author: Tollef Fog Heen Date: Mon Jul 1 14:28:30 2013 +0200 Include vdef.h for __printflike diff --git a/lib/libvarnishapi/vsm_api.h b/lib/libvarnishapi/vsm_api.h index afe4c83..cc0b142 100644 --- a/lib/libvarnishapi/vsm_api.h +++ b/lib/libvarnishapi/vsm_api.h @@ -28,6 +28,8 @@ * */ +#include + struct vsc; struct vsb; From tfheen at varnish-cache.org Mon Jul 1 12:30:09 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 01 Jul 2013 14:30:09 +0200 Subject: [master] a7d8ab6 Documentation: Add backend.set_health state reference. Message-ID: commit a7d8ab66c3376b5f7e03a29d8fd1d86f804a73b3 Author: Trygve Vea Date: Thu Jun 27 13:46:15 2013 +0200 Documentation: Add backend.set_health state reference. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 45bfc92..ef0c5eb 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -80,8 +80,11 @@ backend.list Lists the defined backends including health state. backend.set_health matcher state - Sets the health state on a specific backend. This is useful if - you want to take a certain backend out of circulation. + Sets the health state on a specific backend, overriding the state + determined by a probe. This is useful if you want to take a + certain backend out of circulation. + + *state* can be 'auto', 'sick' or 'healthy'. ban *field operator argument* [&& field operator argument [...]] Immediately invalidate all documents matching the ban From tfheen at varnish-cache.org Mon Jul 1 12:34:45 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 01 Jul 2013 14:34:45 +0200 Subject: [master] ff65d4a Corrected typo Message-ID: commit ff65d4ad09f1dde9a62c1716837e35d9e69156ab Author: InvertedAcceleration Date: Tue Jun 18 14:12:00 2013 +0200 Corrected typo diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 6d5d0ca..1cfaf25 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -275,7 +275,7 @@ When to lock, and when not to lock Varnish is heavily multithreaded, so by default VMODs must implement their own locking to protect shared resources. -When a VCL is loaded or unloaded, the initializtion and teardown +When a VCL is loaded or unloaded, the initialization and teardown is run sequentially in a single thread, and there is guaranteed to be no other activity related to this particular VCL, nor are there init/fini activity in any other VCL or VMOD at this time. From martin at varnish-cache.org Tue Jul 2 13:13:24 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 02 Jul 2013 15:13:24 +0200 Subject: [master] 4e1e53b Remove some leftover defines from old api Message-ID: commit 4e1e53b02db2b8186519db5c5de6f9bfcd79d1d5 Author: Martin Blix Grydeland Date: Tue Jul 2 15:13:00 2013 +0200 Remove some leftover defines from old api diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index d718398..b5d10f8 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -39,15 +39,6 @@ #include "vapi/vsm.h" #include "vapi/vsl_int.h" -#define VSL_ARGS "i:x:" - -#define VSL_i_USAGE "[-i tag]" -#define VSL_x_USAGE "[-x tag]" - -#define VSL_USAGE "[...] " \ - VSL_i_USAGE " " \ - VSL_x_USAGE - struct VSL_data; struct VSLQ; diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index 51e3766..46f5004 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -71,7 +71,6 @@ typedef VTAILQ_HEAD(,vslf) vslf_list; struct VSL_data { unsigned magic; -#undef VSL_MAGIC #define VSL_MAGIC 0x8E6C92AA struct vsb *diag; From martin at varnish-cache.org Tue Jul 2 12:55:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 02 Jul 2013 14:55:57 +0200 Subject: [master] 849a3ff Use VSL_cursor->priv members instead of struct overloading, keeping in line with miniobj coding convention. Message-ID: commit 849a3ffc6fe6cfedd54014c7f5855bbd0a0390e0 Author: Martin Blix Grydeland Date: Tue Jul 2 14:04:44 2013 +0200 Use VSL_cursor->priv members instead of struct overloading, keeping in line with miniobj coding convention. diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index daf5366..d718398 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -59,6 +59,10 @@ struct VSLC_ptr { struct VSL_cursor { /* The record this cursor points to */ struct VSLC_ptr rec; + + /* Private data */ + const void *priv_tbl; + void *priv_data; }; enum VSL_transaction_e { diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index e5a7506..51e3766 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -41,13 +41,16 @@ int vsl_diag(struct VSL_data *vsl, const char *fmt, ...) __printflike(2, 3); int vsl_skip(struct VSL_cursor *c, ssize_t words); -typedef void vslc_delete_f(void *); -typedef int vslc_next_f(void *); -typedef int vslc_reset_f(void *); -typedef int vslc_skip_f(void *, ssize_t words); -typedef int vslc_check_f(const void *, const struct VSLC_ptr *ptr); +typedef void vslc_delete_f(struct VSL_cursor *); +typedef int vslc_next_f(struct VSL_cursor *); +typedef int vslc_reset_f(struct VSL_cursor *); +typedef int vslc_skip_f(struct VSL_cursor *, ssize_t words); +typedef int vslc_check_f(const struct VSL_cursor *, const struct VSLC_ptr *); struct vslc_tbl { + unsigned magic; +#define VSLC_TBL_MAGIC 0x5007C0DE + vslc_delete_f *delete; vslc_next_f *next; vslc_reset_f *reset; @@ -55,14 +58,6 @@ struct vslc_tbl { vslc_check_f *check; }; -struct vslc { - struct VSL_cursor c; - unsigned magic; -#define VSLC_MAGIC 0x5007C0DE - - const struct vslc_tbl *tbl; -}; - struct vslf { unsigned magic; #define VSLF_MAGIC 0x08650B39 diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index 7e72e07..c4f3cf1 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -41,16 +41,18 @@ #include "vas.h" #include "miniobj.h" +#include "vdef.h" #include "vapi/vsm.h" #include "vsm_api.h" #include "vapi/vsl.h" #include "vsl_api.h" struct vslc_vsm { - struct vslc c; unsigned magic; #define VSLC_VSM_MAGIC 0x4D3903A6 + struct VSL_cursor cursor; + struct VSM_data *vsm; struct VSM_fantom vf; @@ -61,21 +63,23 @@ struct vslc_vsm { }; static void -vslc_vsm_delete(void *cursor) +vslc_vsm_delete(struct VSL_cursor *cursor) { struct vslc_vsm *c; - CAST_OBJ_NOTNULL(c, (void *)cursor, VSLC_VSM_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); + assert(&c->cursor == cursor); FREE_OBJ(c); } static int -vslc_vsm_check(const void *cursor, const struct VSLC_ptr *ptr) +vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) { const struct vslc_vsm *c; unsigned seqdiff, segment, segdiff; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VSM_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); + assert(&c->cursor == cursor); if (ptr->ptr == NULL) return (0); @@ -109,13 +113,14 @@ vslc_vsm_check(const void *cursor, const struct VSLC_ptr *ptr) } static int -vslc_vsm_next(void *cursor) +vslc_vsm_next(struct VSL_cursor *cursor) { struct vslc_vsm *c; int i; uint32_t t; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VSM_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); + assert(&c->cursor == cursor); CHECK_OBJ_NOTNULL(c->vsm, VSM_MAGIC); /* Assert pointers */ @@ -123,7 +128,7 @@ vslc_vsm_next(void *cursor) assert(c->next.ptr >= c->head->log); assert(c->next.ptr < c->end); - i = vslc_vsm_check(c, &c->next); + i = vslc_vsm_check(&c->cursor, &c->next); if (i <= 0) /* Overrun */ return (-3); @@ -163,19 +168,20 @@ vslc_vsm_next(void *cursor) if (c->next.ptr == c->head->log) c->next.priv = c->head->seq; - c->c.c.rec = c->next; + c->cursor.rec = c->next; c->next.ptr = VSL_NEXT(c->next.ptr); return (1); } } static int -vslc_vsm_reset(void *cursor) +vslc_vsm_reset(struct VSL_cursor *cursor) { struct vslc_vsm *c; unsigned segment; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VSM_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); + assert(&c->cursor == cursor); /* * Starting (VSL_SEGMENTS - 3) behind varnishd. This way @@ -189,29 +195,31 @@ vslc_vsm_reset(void *cursor) assert(c->head->segments[segment] >= 0); c->next.ptr = c->head->log + c->head->segments[segment]; c->next.priv = c->head->seq; - c->c.c.rec.ptr = NULL; + c->cursor.rec.ptr = NULL; return (0); } static int -vslc_vsm_skip(void *cursor, ssize_t words) +vslc_vsm_skip(struct VSL_cursor *cursor, ssize_t words) { struct vslc_vsm *c; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VSM_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VSM_MAGIC); + assert(&c->cursor == cursor); if (words < 0) return (-1); c->next.ptr += words; assert(c->next.ptr >= c->head->log); assert(c->next.ptr < c->end); - c->c.c.rec.ptr = NULL; + c->cursor.rec.ptr = NULL; return (0); } static const struct vslc_tbl vslc_vsm_tbl = { + .magic = VSLC_TBL_MAGIC, .delete = vslc_vsm_delete, .next = vslc_vsm_next, .reset = vslc_vsm_reset, @@ -249,8 +257,8 @@ VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, int tail) vsl_diag(vsl, "Out of memory\n"); return (NULL); } - c->c.magic = VSLC_MAGIC; - c->c.tbl = & vslc_vsm_tbl; + c->cursor.priv_tbl = &vslc_vsm_tbl; + c->cursor.priv_data = c; c->vsm = vsm; c->vf = vf; @@ -267,17 +275,17 @@ VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, int tail) c->next.ptr = VSL_NEXT(c->next.ptr); c->next.priv = c->head->seq; } else - AZ(vslc_vsm_reset(&c->c)); + AZ(vslc_vsm_reset(&c->cursor)); - /* XXX: How does 'c' ever get freed ? */ - return (&c->c.c); + return (&c->cursor); } struct vslc_file { - struct vslc c; unsigned magic; #define VSLC_FILE_MAGIC 0x1D65FFEF + struct VSL_cursor cursor; + int error; int fd; ssize_t buflen; @@ -285,11 +293,12 @@ struct vslc_file { }; static void -vslc_file_delete(void *cursor) +vslc_file_delete(struct VSL_cursor *cursor) { struct vslc_file *c; - CAST_OBJ_NOTNULL(c, cursor, VSLC_FILE_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_FILE_MAGIC); + assert(&c->cursor == cursor); if (c->fd > STDIN_FILENO) (void)close(c->fd); if (c->buf != NULL) @@ -313,18 +322,19 @@ vslc_file_readn(int fd, void *buf, size_t n) } static int -vslc_file_next(void *cursor) +vslc_file_next(struct VSL_cursor *cursor) { struct vslc_file *c; ssize_t i, l; - CAST_OBJ_NOTNULL(c, cursor, VSLC_FILE_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_FILE_MAGIC); + assert(&c->cursor == cursor); if (c->error) return (c->error); do { - c->c.c.rec.ptr = NULL; + c->cursor.rec.ptr = NULL; assert(c->buflen >= VSL_BYTES(2)); i = vslc_file_readn(c->fd, c->buf, VSL_BYTES(2)); if (i < 0) @@ -347,13 +357,13 @@ vslc_file_next(void *cursor) return (-1); /* EOF */ assert(i == l - VSL_BYTES(2)); } - c->c.c.rec.ptr = c->buf; - } while (VSL_TAG(c->c.c.rec.ptr) == SLT__Batch); + c->cursor.rec.ptr = c->buf; + } while (VSL_TAG(c->cursor.rec.ptr) == SLT__Batch); return (1); } static int -vslc_file_reset(void *cursor) +vslc_file_reset(struct VSL_cursor *cursor) { (void)cursor; /* XXX: Implement me */ @@ -361,6 +371,7 @@ vslc_file_reset(void *cursor) } static const struct vslc_tbl vslc_file_tbl = { + .magic = VSLC_TBL_MAGIC, .delete = vslc_file_delete, .next = vslc_file_next, .reset = vslc_file_reset, @@ -410,67 +421,67 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name) vsl_diag(vsl, "Out of memory\n"); return (NULL); } - c->c.magic = VSLC_MAGIC; - c->c.tbl = &vslc_file_tbl; + c->cursor.priv_tbl = &vslc_file_tbl; + c->cursor.priv_data = c; c->fd = fd; c->buflen = BUFSIZ; c->buf = malloc(c->buflen); AN(c->buf); - return (&c->c.c); + return (&c->cursor); } void VSL_DeleteCursor(struct VSL_cursor *cursor) { - struct vslc *c; + const struct vslc_tbl *tbl; - CAST_OBJ_NOTNULL(c, (void *)cursor, VSLC_MAGIC); - if (c->tbl->delete == NULL) + CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); + if (tbl->delete == NULL) return; - (c->tbl->delete)(c); + (tbl->delete)(cursor); } int VSL_ResetCursor(struct VSL_cursor *cursor) { - struct vslc *c; + const struct vslc_tbl *tbl; - CAST_OBJ_NOTNULL(c, (void *)cursor, VSLC_MAGIC); - if (c->tbl->reset == NULL) + CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); + if (tbl->reset == NULL) return (-1); - return ((c->tbl->reset)(c)); + return ((tbl->reset)(cursor)); } int VSL_Next(struct VSL_cursor *cursor) { - struct vslc *c; + const struct vslc_tbl *tbl; - CAST_OBJ_NOTNULL(c, (void *)cursor, VSLC_MAGIC); - AN(c->tbl->next); - return ((c->tbl->next)(c)); + CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); + AN(tbl->next); + return ((tbl->next)(cursor)); } int vsl_skip(struct VSL_cursor *cursor, ssize_t words) { - struct vslc *c; + const struct vslc_tbl *tbl; - CAST_OBJ_NOTNULL(c, (void *)cursor, VSLC_MAGIC); - if (c->tbl->skip == NULL) + CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); + if (tbl->skip == NULL) return (-1); - return ((c->tbl->skip)(c, words)); + return ((tbl->skip)(cursor, words)); } int VSL_Check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) { - const struct vslc *c; + const struct vslc_tbl *tbl; - CAST_OBJ_NOTNULL(c, (const void *)cursor, VSLC_MAGIC); - if (c->tbl->check == NULL) + CAST_OBJ_NOTNULL(tbl, cursor->priv_tbl, VSLC_TBL_MAGIC); + if (tbl->check == NULL) return (-1); - return ((c->tbl->check)(c, ptr)); + return ((tbl->check)(cursor, ptr)); } diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 592e4b8..bb2da3f 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -51,10 +51,11 @@ struct vtx; struct vslc_raw { - struct vslc c; unsigned magic; #define VSLC_RAW_MAGIC 0x247EBD44 + struct VSL_cursor cursor; + const uint32_t *start; ssize_t len; const uint32_t *next; @@ -67,10 +68,11 @@ struct vtx_chunk { }; struct vslc_vtx { - struct vslc c; unsigned magic; #define VSLC_VTX_MAGIC 0x74C6523F + struct VSL_cursor cursor; + struct vtx *vtx; unsigned chunk; /* Current chunk */ @@ -155,16 +157,17 @@ VRB_PROTOTYPE_STATIC(vtx_tree, vtx_key, entry, vtx_keycmp) VRB_GENERATE_STATIC(vtx_tree, vtx_key, entry, vtx_keycmp) static int -vslc_raw_next(void *cursor) +vslc_raw_next(struct VSL_cursor *cursor) { struct vslc_raw *c; - CAST_OBJ_NOTNULL(c, cursor, VSLC_RAW_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_RAW_MAGIC); + assert(&c->cursor == cursor); assert(c->next >= c->start); assert(c->next <= c->start + c->len); if (c->next < c->start + c->len) { - c->c.c.rec.ptr = c->next; + c->cursor.rec.ptr = c->next; c->next = VSL_NEXT(c->next); return (1); } @@ -172,21 +175,23 @@ vslc_raw_next(void *cursor) } static int -vslc_raw_reset(void *cursor) +vslc_raw_reset(struct VSL_cursor *cursor) { struct vslc_raw *c; - CAST_OBJ_NOTNULL(c, cursor, VSLC_RAW_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_RAW_MAGIC); + assert(&c->cursor == cursor); assert(c->next >= c->start); assert(c->next <= c->start + c->len); c->next = c->start; - c->c.c.rec.ptr = NULL; + c->cursor.rec.ptr = NULL; return (0); } static const struct vslc_tbl vslc_raw_tbl = { + .magic = VSLC_TBL_MAGIC, .delete = NULL, .next = vslc_raw_next, .reset = vslc_raw_reset, @@ -195,12 +200,14 @@ static const struct vslc_tbl vslc_raw_tbl = { }; static int -vslc_vtx_next(void *cursor) +vslc_vtx_next(struct VSL_cursor *cursor) { struct vslc_vtx *c; struct vtx_chunk *chunk; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VTX_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VTX_MAGIC); + assert(&c->cursor == cursor); + CHECK_OBJ_NOTNULL(c->vtx, VTX_MAGIC); assert (c->offset <= c->vtx->len); if (c->offset == c->vtx->len) @@ -210,8 +217,8 @@ vslc_vtx_next(void *cursor) /* Buffer */ AN(c->vtx->buf); assert(c->offset < c->vtx->bufsize); - c->c.c.rec.ptr = c->vtx->buf + c->offset; - c->offset += VSL_NEXT(c->c.c.rec.ptr) - c->c.c.rec.ptr; + c->cursor.rec.ptr = c->vtx->buf + c->offset; + c->offset += VSL_NEXT(c->cursor.rec.ptr) - c->cursor.rec.ptr; return (1); } @@ -225,26 +232,28 @@ vslc_vtx_next(void *cursor) chunk = &c->vtx->chunk[c->chunk]; } AN(chunk->start.ptr); - c->c.c.rec.ptr = chunk->start.ptr + c->offset - chunk->offset; - c->offset += VSL_NEXT(c->c.c.rec.ptr) - c->c.c.rec.ptr; + c->cursor.rec.ptr = chunk->start.ptr + c->offset - chunk->offset; + c->offset += VSL_NEXT(c->cursor.rec.ptr) - c->cursor.rec.ptr; return (1); } static int -vslc_vtx_reset(void *cursor) +vslc_vtx_reset(struct VSL_cursor *cursor) { struct vslc_vtx *c; - CAST_OBJ_NOTNULL(c, cursor, VSLC_VTX_MAGIC); + CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VTX_MAGIC); + assert(&c->cursor == cursor); c->chunk = 0; c->offset = 0; - c->c.c.rec.ptr = NULL; + c->cursor.rec.ptr = NULL; return (0); } static const struct vslc_tbl vslc_vtx_tbl = { + .magic = VSLC_TBL_MAGIC, .delete = NULL, .next = vslc_vtx_next, .reset = vslc_vtx_reset, @@ -266,10 +275,10 @@ vtx_new(struct VSLQ *vslq) } else { ALLOC_OBJ(vtx, VTX_MAGIC); AN(vtx); - vtx->c.c.magic = VSLC_MAGIC; - vtx->c.c.tbl = &vslc_vtx_tbl; vtx->c.magic = VSLC_VTX_MAGIC; vtx->c.vtx = vtx; + vtx->c.cursor.priv_tbl = &vslc_vtx_tbl; + vtx->c.cursor.priv_data = &vtx->c; } vtx->key.vxid = 0; @@ -281,7 +290,7 @@ vtx_new(struct VSLQ *vslq) vtx->n_child = 0; vtx->n_childready = 0; vtx->n_descend = 0; - (void)vslc_vtx_reset(&vtx->c); + (void)vslc_vtx_reset(&vtx->c.cursor); vtx->len = 0; memset(vtx->chunk, 0, sizeof vtx->chunk); vtx->n_chunk = 0; @@ -625,8 +634,8 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) enum VSL_tag_e tag; struct vtx *ret = NULL; - while (vslc_vtx_next(&vtx->c) == 1) { - ptr = vtx->c.c.c.rec.ptr; + while (vslc_vtx_next(&vtx->c.cursor) == 1) { + ptr = vtx->c.cursor.rec.ptr; tag = VSL_TAG(ptr); if (tag == SLT__Batch) @@ -691,9 +700,9 @@ vslq_callback(const struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func, void *priv) { unsigned n = vtx->n_descend + 1; + struct vtx *vtxs[n]; struct VSL_transaction trans[n]; struct VSL_transaction *ptrans[n + 1]; - struct vslc_vtx *c; unsigned i, j; AN(vslq); @@ -709,22 +718,23 @@ vslq_callback(const struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func, return (0); /* Build transaction array */ - (void)vslc_vtx_reset(&vtx->c); + (void)vslc_vtx_reset(&vtx->c.cursor); + vtxs[0] = vtx; trans[0].level = 1; trans[0].vxid = vtx->key.vxid; trans[0].type = vtx->type; - trans[0].c = &vtx->c.c.c; + trans[0].c = &vtx->c.cursor; i = 1; j = 0; while (j < i) { - CAST_OBJ_NOTNULL(c, (void *)trans[j].c, VSLC_VTX_MAGIC); - VTAILQ_FOREACH(vtx, &c->vtx->child, list_child) { + VTAILQ_FOREACH(vtx, &vtxs[j]->child, list_child) { assert(i < n); - (void)vslc_vtx_reset(&vtx->c); + (void)vslc_vtx_reset(&vtx->c.cursor); + vtxs[i] = vtx; trans[i].level = trans[j].level + 1; trans[i].vxid = vtx->key.vxid; trans[i].type = vtx->type; - trans[i].c = &vtx->c.c.c; + trans[i].c = &vtx->c.cursor; i++; } j++; @@ -856,12 +866,12 @@ vslq_raw(const struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv) c = vslq->c; memset(&rawc, 0, sizeof rawc); - rawc.c.magic = VSLC_MAGIC; - rawc.c.tbl = &vslc_raw_tbl; rawc.magic = VSLC_RAW_MAGIC; + rawc.cursor.priv_tbl = &vslc_raw_tbl; + rawc.cursor.priv_data = &rawc; trans.level = 0; trans.type = VSL_t_raw; - trans.c = &rawc.c.c; + trans.c = &rawc.cursor; ptrans[0] = &trans; ptrans[1] = NULL; @@ -875,7 +885,7 @@ vslq_raw(const struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv) rawc.start = c->rec.ptr; rawc.len = VSL_NEXT(c->rec.ptr) - c->rec.ptr; rawc.next = rawc.start; - rawc.c.c.rec.ptr = NULL; + rawc.cursor.rec.ptr = NULL; trans.vxid = VSL_ID(c->rec.ptr); /* Query check goes here */ From tfheen at varnish-cache.org Wed Jul 3 10:11:20 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 03 Jul 2013 12:11:20 +0200 Subject: [master] a48b091 Install a SIGSEGV handler Message-ID: commit a48b09161fd558489406b198de096705f90f82bf Author: Tollef Fog Heen Date: Wed Jul 3 12:06:41 2013 +0200 Install a SIGSEGV handler If we happen to get a SIGSEGV, call the panic handler. It might not work, but it's better than nothing and hopefully we can get some useful diagnostics. diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index c00d427..dc5f234 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -210,6 +210,9 @@ struct params { unsigned bo_cache; + /* Install a SIGSEGV handler */ + unsigned sigsegv_handler; + /* VSM dimensions */ ssize_t vsm_space; ssize_t vsl_space; diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 9397891..89e8f4a 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -312,6 +312,25 @@ child_poker(const struct vev *e, int what) } /*===================================================================== + * SIGSEGV handler + */ + +static void mgt_sigsegv_handler(int s, siginfo_t *si, void *c) { + char buf[1024]; + + (void)s; + (void)c; + + sprintf(buf, "Segmentation fault by instruction at %p", si->si_addr); + VAS_Fail(__func__, + __FILE__, + __LINE__, + buf, + errno, + 0); +} + +/*===================================================================== * Launch the child process */ @@ -323,6 +342,7 @@ mgt_launch_child(struct cli *cli) char *p; struct vev *e; int i, cp[2]; + struct sigaction sa; if (child_state != CH_STOPPED && child_state != CH_DIED) return; @@ -390,6 +410,11 @@ mgt_launch_child(struct cli *cli) setproctitle("Varnish-Chld %s", heritage.name); #endif + if (mgt_param.sigsegv_handler) { + sa.sa_sigaction = mgt_sigsegv_handler; + sa.sa_flags = SA_SIGINFO; + (void)sigaction(SIGSEGV, &sa, NULL); + } (void)signal(SIGINT, SIG_DFL); (void)signal(SIGTERM, SIG_DFL); diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 82ed98f..65a70b5 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -507,6 +507,11 @@ const struct parspec mgt_parspec[] = { "on the cooloff list.\n", WIZARD, "180.0", "s" }, + { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, 0, 0, + "Install a signal handler which tries to dump debug information " + "on segmentation faults.\n", + MUST_RESTART, + "off", "bool" }, { "vcl_dir", tweak_string, &mgt_vcl_dir, 0, 0, "Directory from which relative VCL filenames (vcl.load and " "include) are opened.", diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc new file mode 100644 index 0000000..46469b7 --- /dev/null +++ b/bin/varnishtest/tests/c00057.vtc @@ -0,0 +1,19 @@ +varnishtest "test sigsegv handler" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -cliok "param.set sigsegv_handler on" -vcl+backend { + C{ +#include +}C + sub vcl_recv { C{ raise(SIGSEGV); }C } +} -start + +client c1 { + txreq +} -run + +varnish v1 -cliok "panic.show" From phk at varnish-cache.org Wed Jul 3 11:02:59 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Jul 2013 13:02:59 +0200 Subject: [master] 5a47758 Give the panic a second to happen... Message-ID: commit 5a477589fd1b3cebf244ee7ebe635e16f3653035 Author: Poul-Henning Kamp Date: Wed Jul 3 11:02:47 2013 +0000 Give the panic a second to happen... diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index 46469b7..c8d3bc9 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -16,4 +16,6 @@ client c1 { txreq } -run +delay 1 + varnish v1 -cliok "panic.show" From phk at varnish-cache.org Wed Jul 3 12:22:00 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Jul 2013 14:22:00 +0200 Subject: [master] d519658 A bit of polish Message-ID: commit d519658e5c04638405ff7ea2559517e6da72eb1d Author: Poul-Henning Kamp Date: Wed Jul 3 12:21:46 2013 +0000 A bit of polish diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 89e8f4a..850dc4a 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -312,10 +312,11 @@ child_poker(const struct vev *e, int what) } /*===================================================================== - * SIGSEGV handler + * SIGSEGV handler for child process */ -static void mgt_sigsegv_handler(int s, siginfo_t *si, void *c) { +static void __match_proto__() +mgt_sigsegv_handler(int s, siginfo_t *si, void *c) { char buf[1024]; (void)s; @@ -327,7 +328,7 @@ static void mgt_sigsegv_handler(int s, siginfo_t *si, void *c) { __LINE__, buf, errno, - 0); + VAS_ASSERT); } /*===================================================================== From phk at varnish-cache.org Wed Jul 3 12:23:50 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 03 Jul 2013 14:23:50 +0200 Subject: [master] 0ad1299 Now that we can retry fetches, we have to keep things straight: Message-ID: commit 0ad12998f4af74509f04a0901918d3f224ea4007 Author: Poul-Henning Kamp Date: Wed Jul 3 12:22:23 2013 +0000 Now that we can retry fetches, we have to keep things straight: bereq.uncacheable is our *intention* to pass beresp.uncacheable is the *consequence* if we pass. This way it is possible to fetch as miss first time, and try for a pass on retry. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f08feeb..afef220 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -543,7 +543,10 @@ struct busyobj { unsigned do_gzip; unsigned do_gunzip; unsigned do_stream; + + /* do_pass is our intent, uncacheable is the result */ unsigned do_pass; + unsigned uncacheable; /* Timeouts */ double connect_timeout; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index fe12452..3488954 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -54,7 +54,7 @@ vbf_release_req(struct req ***reqpp) } /*-------------------------------------------------------------------- - * Copy req->bereq and run it by VCL::vcl_backend_fetch{} + * Copy req->bereq */ static enum fetch_step @@ -92,13 +92,12 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo, } /*-------------------------------------------------------------------- - * Copy req->bereq and run it by VCL::vcl_backend_fetch{} + * Copy run bereq by VCL::vcl_backend_fetch{} */ static enum fetch_step vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) { - int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -111,10 +110,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq); HTTP_Copy(bo->bereq, bo->bereq0); - // Don't let VCL reset do_pass - i = bo->do_pass; VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws); - bo->do_pass |= i; + + bo->uncacheable = bo->do_pass; http_PrintfHeader(bo->bereq, "X-Varnish: %u", bo->vsl->wid & VSL_IDENTMASK); @@ -199,10 +197,7 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo, struct req ***reqpp) AZ(bo->do_esi); - // Don't let VCL reset do_pass - i = bo->do_pass; VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); - bo->do_pass |= i; if (wrk->handling == VCL_RET_DELIVER) return (F_STP_FETCH); @@ -237,7 +232,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); assert(wrk->handling == VCL_RET_DELIVER); - if (bo->do_pass) + if (bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; /* @@ -294,48 +289,15 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) else if (bo->is_gzip) bo->vfp = &vfp_testgzip; - -#if 0 - if (wrk->handling != VCL_RET_DELIVER) - VDI_CloseFd(&bo->vbc); - - if (wrk->handling != VCL_RET_DELIVER) { - /* Clean up partial fetch */ - AZ(bo->vbc); - - if (bo->fetch_objcore->objhead != NULL || - wrk->handling == VCL_RET_RESTART || - wrk->handling == VCL_RET_ERROR) { - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); - AZ(HSH_Deref(&wrk->stats, bo->fetch_objcore, NULL)); - bo->fetch_objcore = NULL; - } - assert(bo->refcount == 2); - bo->storage_hint = NULL; - bo->director = NULL; - - switch (wrk->handling) { - case VCL_RET_ERROR: - bo->state = BOS_FAILED; - VBO_DerefBusyObj(wrk, &bo); // XXX ? - return (F_STP_DONE); - case VCL_RET_RESTART: - INCOMPL(); - default: - WRONG("Illegal action in vcl_fetch{}"); - } - } -#endif - if (bo->fetch_objcore->objhead == NULL) - AN(bo->do_pass); + AN(bo->uncacheable); /* No reason to try streaming a non-existing body */ if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; l = http_EstimateWS(bo->beresp, - bo->do_pass ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp); + bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp); /* Create Vary instructions */ if (bo->fetch_objcore->objhead != NULL) { @@ -356,7 +318,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) AZ(vary); } - if (bo->exp.ttl < cache_param->shortlived || bo->do_pass == 1) + if (bo->exp.ttl < cache_param->shortlived || bo->uncacheable == 1) bo->storage_hint = TRANSIENT_STORAGE; /* @@ -413,7 +375,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) hp2 = obj->http; hp2->logtag = HTTP_Obj; - http_FilterResp(hp, hp2, bo->do_pass ? HTTPH_R_PASS : HTTPH_A_INS); + http_FilterResp(hp, hp2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); http_CopyHome(hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 0491b30..1429602 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -144,8 +144,52 @@ VBERESP(beresp, unsigned, do_esi, do_esi) VBERESP(beresp, unsigned, do_gzip, do_gzip) VBERESP(beresp, unsigned, do_gunzip, do_gunzip) VBERESP(beresp, unsigned, do_stream, do_stream) -VBERESP(beresp, unsigned, do_pass, do_pass) -VBERESP(beresp, unsigned, uncacheable, do_pass) + +/*--------------------------------------------------------------------*/ + +void +VRT_l_bereq_uncacheable(const struct vrt_ctx *ctx, unsigned a) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + + if (ctx->bo->do_pass && !a) { + VSLb(ctx->vsl, SLT_VCL_Error, + "Ignoring attempt to reset bereq.uncacheable"); + } else if (a) { + ctx->bo->do_pass = a; + } +} + +unsigned +VRT_r_bereq_uncacheable(const struct vrt_ctx *ctx) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + return (ctx->bo->do_pass); +} + +void +VRT_l_beresp_uncacheable(const struct vrt_ctx *ctx, unsigned a) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + + if (ctx->bo->uncacheable && !a) { + VSLb(ctx->vsl, SLT_VCL_Error, + "Ignoring attempt to reset beresp.uncacheable"); + } else if (a) { + ctx->bo->uncacheable = a; + } +} + +unsigned +VRT_r_beresp_uncacheable(const struct vrt_ctx *ctx) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + return (ctx->bo->uncacheable); +} /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index 520bc06..267b3c8 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -135,7 +135,7 @@ sub vcl_backend_response { * Mark as "Hit-For-Pass" for the next 2 minutes */ set beresp.ttl = 120 s; - set beresp.do_pass = true; + set beresp.uncacheable = true; } return (deliver); } diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index ef3f109..1226b1e 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -257,6 +257,11 @@ sp_variables = ( ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ( 'pipe', 'backend_fetch', 'pass', 'miss', 'backend_response',), ), + ('bereq.uncacheable', + 'BOOL', + ( 'backend_fetch', 'backend_response',), + ( 'backend_fetch', 'backend_response',), + ), ('bereq.connect_timeout', 'DURATION', ( 'pipe', 'backend_fetch', 'pass', 'miss',), @@ -317,11 +322,6 @@ sp_variables = ( ( 'backend_response',), ( 'backend_response',), ), - ('beresp.do_pass', - 'BOOL', - ( 'backend_response',), - ( 'backend_response',), - ), ('beresp.uncacheable', 'BOOL', ( 'backend_response',), From phk at varnish-cache.org Thu Jul 4 09:23:47 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 04 Jul 2013 11:23:47 +0200 Subject: [master] 0c3acbd If we get an illegal og bogus Vary: header from the backend, turn the transaction into a "pass" and complain in VSL. Message-ID: commit 0c3acbd699bc67ca5a3e98648f7f92ef93e34378 Author: Poul-Henning Kamp Date: Thu Jul 4 09:22:50 2013 +0000 If we get an illegal og bogus Vary: header from the backend, turn the transaction into a "pass" and complain in VSL. Previously we faulted the fetch, but that was overly draconian. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 3488954..b55096a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -232,8 +232,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); assert(wrk->handling == VCL_RET_DELIVER); - if (bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; /* * The VCL variables beresp.do_g[un]zip tells us how we want the @@ -307,17 +305,23 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(varyl == VSB_len(vary)); l += varyl; } else if (varyl < 0) { - /* Vary parse error */ + /* + * Vary parse error + * Complain about it, and make this a pass. + */ + VSLb(bo->vsl, SLT_Error, + "Illegal 'Vary' header from backend, " + "making this a pass."); + bo->uncacheable = 1; AZ(vary); - AZ(HSH_Deref(&wrk->stats, bo->fetch_objcore, NULL)); - bo->fetch_objcore = NULL; - VDI_CloseFd(&bo->vbc); - return (F_STP_ABANDON); } else /* No vary */ AZ(vary); } + if (bo->uncacheable) + bo->fetch_objcore->flags |= OC_F_PASS; + if (bo->exp.ttl < cache_param->shortlived || bo->uncacheable == 1) bo->storage_hint = TRANSIENT_STORAGE; diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index f12f128..5402e1f 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -169,3 +169,5 @@ -e747 // 297 Significant prototype coercion (___) ___ to ___ -e840 // Use of nul character in a string literal (see: vcc_if.c) -e663 // Suspicious array to pointer conversion +-e778 // Constant expression evaluates to 0 in operation '___' + diff --git a/bin/varnishtest/tests/r00763.vtc b/bin/varnishtest/tests/r00763.vtc index 72fced4..bd6f80e 100644 --- a/bin/varnishtest/tests/r00763.vtc +++ b/bin/varnishtest/tests/r00763.vtc @@ -3,6 +3,8 @@ varnishtest "Vary header with extra colon" server s1 { rxreq txresp -hdr "Vary:: foo" -hdr "Foo: bar" -bodylen 9 + rxreq + txresp -hdr "Vary:: foo" -hdr "Foo: bar" -bodylen 8 } -start varnish v1 -vcl+backend {} -start @@ -10,5 +12,10 @@ varnish v1 -vcl+backend {} -start client c1 { txreq rxresp - expect resp.status == 503 + expect resp.status == 200 + expect resp.bodylen == 9 + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 8 } -run diff --git a/bin/varnishtest/tests/r01274.vtc b/bin/varnishtest/tests/r01274.vtc index fe427cc..90cd95d 100644 --- a/bin/varnishtest/tests/r01274.vtc +++ b/bin/varnishtest/tests/r01274.vtc @@ -3,7 +3,10 @@ varnishtest "#1274 - panic when Vary field-name is too large to fit in a signed server s1 { rxreq # Vary header more than 127 characters long - txresp -hdr "Vary: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + txresp -hdr "Vary: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -bodylen 9 + rxreq + # Vary header more than 127 characters long + txresp -hdr "Vary: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -bodylen 8 } -start varnish v1 -vcl+backend { } -start @@ -11,5 +14,10 @@ varnish v1 -vcl+backend { } -start client c1 { txreq rxresp - expect resp.status == 503 + expect resp.status == 200 + expect resp.bodylen == 9 + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 8 } -run diff --git a/bin/varnishtest/tests/r01275.vtc b/bin/varnishtest/tests/r01275.vtc index 72c7184..913bb0e 100644 --- a/bin/varnishtest/tests/r01275.vtc +++ b/bin/varnishtest/tests/r01275.vtc @@ -10,5 +10,5 @@ varnish v1 -vcl+backend { } -start client c1 { txreq rxresp - expect resp.status == 503 + expect resp.status == 200 } -run From phk at varnish-cache.org Thu Jul 4 09:50:01 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 04 Jul 2013 11:50:01 +0200 Subject: [master] 8387d18 Just put the origin req in busyobj and make cache_fetch.c a lot simpler Message-ID: commit 8387d183748345556c32370c67bf2b17eb316d1a Author: Poul-Henning Kamp Date: Thu Jul 4 09:49:41 2013 +0000 Just put the origin req in busyobj and make cache_fetch.c a lot simpler diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index afef220..6dd9606 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -511,6 +511,7 @@ struct busyobj { unsigned refcount; double t_fetch; uint16_t err_code; + struct req *req; uint8_t *vary; unsigned is_gzip; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b55096a..e814522 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -45,12 +45,10 @@ */ static void -vbf_release_req(struct req ***reqpp) +vbf_release_req(struct busyobj *bo) { - if (*reqpp != NULL) { - **reqpp = NULL; - *reqpp = NULL; - } + if (bo->req != NULL) + bo->req = NULL; } /*-------------------------------------------------------------------- @@ -58,13 +56,12 @@ vbf_release_req(struct req ***reqpp) */ static enum fetch_step -vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo, - const struct req *req) +vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); AN(bo->director); AZ(bo->vbc); @@ -72,7 +69,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo, AZ(bo->storage_hint); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, HTTP_Bereq); - http_FilterReq(bo->bereq0, req->http, + http_FilterReq(bo->bereq0, bo->req->http, bo->do_pass ? HTTPH_R_PASS : HTTPH_R_FETCH); if (!bo->do_pass) { // XXX: Forcing GET should happen in vcl_miss{} ? @@ -126,12 +123,11 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) */ static enum fetch_step -vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo, struct req ***reqpp) +vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) { int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(reqpp); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); xxxassert (wrk->handling == VCL_RET_FETCH); @@ -139,9 +135,9 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo, struct req ***reqpp) HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp); if (!bo->do_pass) - vbf_release_req(reqpp); + vbf_release_req(bo); /* XXX: retry ?? */ - i = V1F_fetch_hdr(wrk, bo, *reqpp ? **reqpp : NULL); + i = V1F_fetch_hdr(wrk, bo, bo->req); /* * If we recycle a backend connection, there is a finite chance * that the backend closed it before we get a request to it. @@ -149,11 +145,13 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo, struct req ***reqpp) */ if (i == 1) { VSC_C_main->backend_retry++; - i = V1F_fetch_hdr(wrk, bo, *reqpp ? **reqpp : NULL); + i = V1F_fetch_hdr(wrk, bo, bo->req); } if (bo->do_pass) - vbf_release_req(reqpp); + vbf_release_req(bo); /* XXX : retry ?? */ + + AZ(bo->req); if (i) { AZ(bo->vbc); @@ -426,15 +424,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) */ static enum fetch_step -vbf_stp_abandon(struct worker *wrk, struct busyobj *bo, struct req ***reqp) +vbf_stp_abandon(struct worker *wrk, struct busyobj *bo) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(reqp); bo->state = BOS_FAILED; + vbf_release_req(bo); VBO_DerefBusyObj(wrk, &bo); // XXX ? - vbf_release_req(reqp); return (F_STP_DONE); } @@ -461,13 +458,6 @@ vbf_stp_done(void) /*-------------------------------------------------------------------- */ -struct vbf_secret_handshake { - unsigned magic; -#define VBF_SECRET_HANDSHAKE_MAGIC 0x98c95172 - struct busyobj *bo; - struct req **reqp; -}; - static const char * vbf_step_name(enum fetch_step stp) { @@ -486,17 +476,12 @@ vbf_step_name(enum fetch_step stp) static void vbf_fetch_thread(struct worker *wrk, void *priv) { - struct vbf_secret_handshake *vsh; struct busyobj *bo; - struct req **reqp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CAST_OBJ_NOTNULL(vsh, priv, VBF_SECRET_HANDSHAKE_MAGIC); - AN(vsh->reqp); - reqp = vsh->reqp; - CHECK_OBJ_NOTNULL((*vsh->reqp), REQ_MAGIC); + CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); - bo = vsh->bo; THR_SetBusyobj(bo); bo->step = F_STP_MKBEREQ; @@ -524,7 +509,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) void VBF_Fetch(struct worker *wrk, struct req *req) { - struct vbf_secret_handshake vsh; struct busyobj *bo; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -536,19 +520,19 @@ VBF_Fetch(struct worker *wrk, struct req *req) assert(bo->refcount == 2); CHECK_OBJ_NOTNULL(bo->vcl, VCL_CONF_MAGIC); + AZ(bo->fetch_objcore); bo->fetch_objcore = req->objcore; req->objcore = NULL; - vsh.magic = VBF_SECRET_HANDSHAKE_MAGIC; - vsh.bo = bo; - vsh.reqp = &req; + AZ(bo->req); + bo->req = req; - bo->fetch_task.priv = &vsh; + bo->fetch_task.priv = bo; bo->fetch_task.func = vbf_fetch_thread; if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_QUEUE_FRONT)) - vbf_fetch_thread(wrk, &vsh); - while (req != NULL) { + vbf_fetch_thread(wrk, bo); + while (bo->req != NULL) { printf("XXX\n"); (void)usleep(100000); } diff --git a/include/tbl/steps.h b/include/tbl/steps.h index 9767191..6f219e4 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -50,11 +50,11 @@ REQ_STEP(error, ERROR, (wrk, req)) #endif #ifdef FETCH_STEP -FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo, *reqp)) +FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo)) FETCH_STEP(startfetch, STARTFETCH, (wrk, bo)) -FETCH_STEP(fetchhdr, FETCHHDR, (wrk, bo, &reqp)) +FETCH_STEP(fetchhdr, FETCHHDR, (wrk, bo)) FETCH_STEP(fetch, FETCH, (wrk, bo)) -FETCH_STEP(abandon, ABANDON, (wrk, bo, &reqp)) +FETCH_STEP(abandon, ABANDON, (wrk, bo)) FETCH_STEP(notyet, NOTYET, ()) FETCH_STEP(done, DONE, ()) #endif From phk at varnish-cache.org Fri Jul 5 09:20:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 05 Jul 2013 11:20:27 +0200 Subject: [master] 9e6bbcb Add a "body present" state for req.body Message-ID: commit 9e6bbcbab35cdef234cb32a704499866f8fd43af Author: Poul-Henning Kamp Date: Fri Jul 5 07:55:14 2013 +0000 Add a "body present" state for req.body diff --git a/include/tbl/req_body.h b/include/tbl/req_body.h index 59f87fb..b6602cb 100644 --- a/include/tbl/req_body.h +++ b/include/tbl/req_body.h @@ -30,7 +30,10 @@ /*lint -save -e525 -e539 */ REQ_BODY(INIT) +REQ_BODY(PRESENT) REQ_BODY(CACHED) REQ_BODY(DONE) REQ_BODY(FAIL) REQ_BODY(NONE) + +/*lint -restore */ From phk at varnish-cache.org Fri Jul 5 09:20:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 05 Jul 2013 11:20:27 +0200 Subject: [master] 1f356ed Be more correct Message-ID: commit 1f356ed6bb72426e7322e1657959c6d32f7437db Author: Poul-Henning Kamp Date: Fri Jul 5 08:14:49 2013 +0000 Be more correct diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 90ffc21..68aa284 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -429,6 +429,7 @@ http1_setup_req_body(struct req *req, struct http1_r_b_s *rbs) } rbs->mode = CL; rbs->yet = req->req_bodybytes - rbs->bytes_done; + req->req_body_status = REQ_BODY_PRESENT; return (0); } @@ -436,7 +437,7 @@ http1_setup_req_body(struct req *req, struct http1_r_b_s *rbs) rbs->mode = CHUNKED; VSLb(req->vsl, SLT_Debug, "Transfer-Encoding in request"); - req->req_body_status = REQ_BODY_DONE; + req->req_body_status = REQ_BODY_FAIL; return (-1); } From phk at varnish-cache.org Fri Jul 5 09:20:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 05 Jul 2013 11:20:27 +0200 Subject: [master] 51cd672 Move the HTTP1 specific req.body housekeeping into struct req, but sequester it and mark it HTTP1 specific Message-ID: commit 51cd67291dad4a07297622edfdf79c52c2e6c622 Author: Poul-Henning Kamp Date: Fri Jul 5 09:19:46 2013 +0000 Move the HTTP1 specific req.body housekeeping into struct req, but sequester it and mark it HTTP1 specific diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6dd9606..4515dd1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -620,8 +620,15 @@ struct req { enum req_step req_step; VTAILQ_ENTRY(req) w_list; + enum req_body_state_e req_body_status; struct storagehead body; + struct { + ssize_t bytes_done; + ssize_t bytes_yet; + enum {CL, CHUNKED} mode; + } h1; /* HTTP1 specific */ + /* The busy objhead we sleep on */ struct objhead *hash_objhead; struct busyobj *busyobj; @@ -637,7 +644,6 @@ struct req { struct exp exp; unsigned char wantbody; - enum req_body_state_e req_body_status; uint64_t req_bodybytes; uint64_t resp_bodybytes; diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 68aa284..b9bbacf 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -397,19 +397,13 @@ HTTP1_Session(struct worker *wrk, struct req *req) /*---------------------------------------------------------------------- */ -struct http1_r_b_s { - ssize_t bytes_done; - ssize_t yet; - enum {CL, CHUNKED} mode; -}; - static int -http1_setup_req_body(struct req *req, struct http1_r_b_s *rbs) +http1_setup_req_body(struct req *req) { char *ptr, *endp; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - memset(rbs, 0, sizeof *rbs); + memset(&req->h1, 0, sizeof req->h1); assert(req->req_body_status == REQ_BODY_INIT); if (http_GetHdr(req->http, H_Content_Length, &ptr)) { @@ -427,14 +421,14 @@ http1_setup_req_body(struct req *req, struct http1_r_b_s *rbs) req->req_body_status = REQ_BODY_NONE; return (0); } - rbs->mode = CL; - rbs->yet = req->req_bodybytes - rbs->bytes_done; + req->h1.mode = CL; + req->h1.bytes_yet = req->req_bodybytes - req->h1.bytes_done; req->req_body_status = REQ_BODY_PRESENT; return (0); } if (http_GetHdr(req->http, H_Transfer_Encoding, NULL)) { - rbs->mode = CHUNKED; + req->h1.mode = CHUNKED; VSLb(req->vsl, SLT_Debug, "Transfer-Encoding in request"); req->req_body_status = REQ_BODY_FAIL; @@ -447,17 +441,17 @@ http1_setup_req_body(struct req *req, struct http1_r_b_s *rbs) } static ssize_t -http1_iter_req_body(struct req *req, struct http1_r_b_s *rbs, void *buf, +http1_iter_req_body(struct req *req, void *buf, ssize_t len) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (rbs->mode == CL) { + if (req->h1.mode == CL) { AN(req->req_bodybytes); AN(len); AN(buf); - if (len > req->req_bodybytes - rbs->bytes_done) - len = req->req_bodybytes - rbs->bytes_done; + if (len > req->req_bodybytes - req->h1.bytes_done) + len = req->req_bodybytes - req->h1.bytes_done; if (len == 0) { req->req_body_status = REQ_BODY_DONE; return (0); @@ -467,8 +461,8 @@ http1_iter_req_body(struct req *req, struct http1_r_b_s *rbs, void *buf, req->req_body_status = REQ_BODY_FAIL; return (-1); } - rbs->bytes_done += len; - rbs->yet = req->req_bodybytes - rbs->bytes_done; + req->h1.bytes_done += len; + req->h1.bytes_yet = req->req_bodybytes - req->h1.bytes_done; return (len); } INCOMPL(); @@ -488,7 +482,6 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) struct storage *st; ssize_t l; int i; - struct http1_r_b_s rbs; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); @@ -508,7 +501,7 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) if (req->req_body_status != REQ_BODY_INIT) return (-1); - i = http1_setup_req_body(req, &rbs); + i = http1_setup_req_body(req); if (i < 0) return (i); @@ -516,7 +509,7 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) return (0); do { - l = http1_iter_req_body(req, &rbs, buf, sizeof buf); + l = http1_iter_req_body(req, buf, sizeof buf); if (l < 0) return (l); if (l > 0) { @@ -562,7 +555,6 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) struct storage *st; ssize_t l; int i; - struct http1_r_b_s rbs; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -575,7 +567,7 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) if (req->req_body_status != REQ_BODY_INIT) return (-1); - i = http1_setup_req_body(req, &rbs); + i = http1_setup_req_body(req); if (i < 0) return (i); @@ -591,7 +583,8 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) do { if (st == NULL) { st = STV_alloc_transient( - rbs.yet ? rbs.yet : cache_param->fetch_chunksize); + req->h1.bytes_yet ? + req->h1.bytes_yet : cache_param->fetch_chunksize); if (st == NULL) { req->req_body_status = REQ_BODY_FAIL; return (-1); @@ -601,7 +594,7 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) } l = st->space - st->len; - l = http1_iter_req_body(req, &rbs, st->ptr + st->len, l); + l = http1_iter_req_body(req, st->ptr + st->len, l); if (l < 0) return (l); if (req->req_bodybytes > maxsize) { From phk at varnish-cache.org Fri Jul 5 10:53:18 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 05 Jul 2013 12:53:18 +0200 Subject: [master] 52d289f Add a stringifier for enum req_body_state_e e Message-ID: commit 52d289ff2f41dbddb9902737e7310d01fa7e30da Author: Poul-Henning Kamp Date: Fri Jul 5 10:53:05 2013 +0000 Add a stringifier for enum req_body_state_e e diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4515dd1..fbf0989 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -981,6 +981,7 @@ void MPL_Free(struct mempool *mpl, void *item); /* cache_panic.c */ void PAN_Init(void); const char *body_status_2str(enum body_status e); +const char *reqbody_status_2str(enum req_body_state_e e); const char *sess_close_2str(enum sess_close sc, int want_desc); /* cache_pipe.c */ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 824c53a..d7ab8f8 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -76,6 +76,20 @@ body_status_2str(enum body_status e) /*--------------------------------------------------------------------*/ const char * +reqbody_status_2str(enum req_body_state_e e) +{ + switch (e) { +#define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U); break; +#include "tbl/req_body.h" +#undef REQ_BODY + default: + return("?"); + } +} + +/*--------------------------------------------------------------------*/ + +const char * sess_close_2str(enum sess_close sc, int want_desc) { switch (sc) { @@ -273,7 +287,7 @@ pan_busyobj(const struct busyobj *bo) static void pan_req(const struct req *req) { - const char *stp, *body; + const char *stp; VSB_printf(pan_vsp, "req = %p {\n", req); @@ -290,17 +304,8 @@ pan_req(const struct req *req) else VSB_printf(pan_vsp, " step = 0x%x,\n", req->req_step); - switch (req->req_body_status) { -#define REQ_BODY(U) case REQ_BODY_##U: body = "R_BODY_" #U; break; -#include "tbl/req_body.h" -#undef REQ_BODY - default: body = NULL; - } - if (body != NULL) - VSB_printf(pan_vsp, " req_body = %s,\n", body); - else - VSB_printf(pan_vsp, " req_body = 0x%x,\n", - req->req_body_status); + VSB_printf(pan_vsp, " req_body = %s,\n", + reqbody_status_2str(req->req_body_status)); if (req->err_code) VSB_printf(pan_vsp, From phk at varnish-cache.org Fri Jul 5 11:07:11 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 05 Jul 2013 13:07:11 +0200 Subject: [master] 5f122e8 Determine req.body status earlier and add more paranioa around that state. Message-ID: commit 5f122e8374f4c50fdfeb144d0a7ba081be9cceae Author: Poul-Henning Kamp Date: Fri Jul 5 11:06:39 2013 +0000 Determine req.body status earlier and add more paranioa around that state. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 041626f..76fc1c5 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -60,6 +60,7 @@ ved_include(struct req *preq, const char *src, const char *host) wrk_ws_wm = WS_Snapshot(wrk->aws); /* XXX ? */ req = SES_GetReq(wrk, preq->sp); + req->req_body_status = REQ_BODY_NONE; VSLb(req->vsl, SLT_Begin, "esireq %u", preq->vsl->wid & VSL_IDENTMASK); VSLb(preq->vsl, SLT_Link, "esireq %u", req->vsl->wid & VSL_IDENTMASK); req->esi_level = preq->esi_level + 1; diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index b9bbacf..d4a296a 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -201,6 +201,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->t_req = NAN; req->t_resp = NAN; + req->req_body_status = REQ_BODY_INIT; // req->req_bodybytes = 0; req->resp_bodybytes = 0; @@ -239,6 +240,38 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) /*---------------------------------------------------------------------- */ +static enum req_body_state_e +http1_req_body_status(struct req *req) +{ + char *ptr, *endp; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + if (http_GetHdr(req->http, H_Content_Length, &ptr)) { + AN(ptr); + if (*ptr == '\0') + return (REQ_BODY_FAIL); + req->req_bodybytes = strtoul(ptr, &endp, 10); + if (*endp != '\0' && !vct_islws(*endp)) + return (REQ_BODY_FAIL); + if (req->req_bodybytes == 0) + return (REQ_BODY_NONE); + req->h1.mode = CL; + req->h1.bytes_yet = req->req_bodybytes - req->h1.bytes_done; + return (REQ_BODY_PRESENT); + } + + if (http_GetHdr(req->http, H_Transfer_Encoding, NULL)) { + req->h1.mode = CHUNKED; + VSLb(req->vsl, SLT_Debug, "Transfer-Encoding in request"); + return (REQ_BODY_FAIL); + } + return (REQ_BODY_NONE); +} + +/*---------------------------------------------------------------------- + */ + static enum req_fsm_nxt http1_dissect(struct worker *wrk, struct req *req) { @@ -248,6 +281,8 @@ http1_dissect(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + memset(&req->h1, 0, sizeof req->h1); + /* * Cache_req_fsm zeros the vxid once a requests is processed. * Allocate a new one only now that we know will need it. @@ -294,8 +329,12 @@ http1_dissect(struct worker *wrk, struct req *req) wrk->stats.client_req++; http_Unset(req->http, H_Expect); - /* XXX: pull in req-body and make it available instead. */ - req->req_body_status = REQ_BODY_INIT; + if (req->req_body_status == REQ_BODY_INIT) + req->req_body_status = http1_req_body_status(req); + else + assert(req->req_body_status == REQ_BODY_NONE); + + assert(req->req_body_status != REQ_BODY_INIT); HTTP_Copy(req->http0, req->http); // For ESI & restart @@ -394,55 +433,8 @@ HTTP1_Session(struct worker *wrk, struct req *req) } } -/*---------------------------------------------------------------------- - */ - -static int -http1_setup_req_body(struct req *req) -{ - char *ptr, *endp; - - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - memset(&req->h1, 0, sizeof req->h1); - - assert(req->req_body_status == REQ_BODY_INIT); - if (http_GetHdr(req->http, H_Content_Length, &ptr)) { - AN(ptr); - if (*ptr == '\0') { - req->req_body_status = REQ_BODY_FAIL; - return (-1); - } - req->req_bodybytes = strtoul(ptr, &endp, 10); - if (*endp != '\0' && !vct_islws(*endp)) { - req->req_body_status = REQ_BODY_FAIL; - return (-1); - } - if (req->req_bodybytes == 0) { - req->req_body_status = REQ_BODY_NONE; - return (0); - } - req->h1.mode = CL; - req->h1.bytes_yet = req->req_bodybytes - req->h1.bytes_done; - req->req_body_status = REQ_BODY_PRESENT; - return (0); - } - - if (http_GetHdr(req->http, H_Transfer_Encoding, NULL)) { - req->h1.mode = CHUNKED; - VSLb(req->vsl, SLT_Debug, - "Transfer-Encoding in request"); - req->req_body_status = REQ_BODY_FAIL; - return (-1); - } - - req->req_body_status = REQ_BODY_NONE; - req->req_bodybytes = 0; - return (0); -} - static ssize_t -http1_iter_req_body(struct req *req, void *buf, - ssize_t len) +http1_iter_req_body(struct req *req, void *buf, ssize_t len) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -486,36 +478,31 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); - if (req->req_body_status == REQ_BODY_CACHED) { + switch(req->req_body_status) { + case REQ_BODY_CACHED: VTAILQ_FOREACH(st, &req->body, list) { i = func(req, priv, st->ptr, st->len); if (i) return (i); } return (0); - } - - if (req->req_body_status == REQ_BODY_NONE) + case REQ_BODY_NONE: return (0); - - if (req->req_body_status != REQ_BODY_INIT) - return (-1); - - i = http1_setup_req_body(req); - if (i < 0) - return (i); - - if (req->req_body_status == REQ_BODY_NONE) - return (0); - + case REQ_BODY_PRESENT: + break; + default: + WRONG("Wrong req_body_status in HTTP1_IterateReqBody()"); + } do { l = http1_iter_req_body(req, buf, sizeof buf); - if (l < 0) + if (l < 0) { return (l); + } if (l > 0) { i = func(req, priv, buf, l); - if (i) + if (i) { return (i); + } } } while (l > 0); return(0); @@ -542,6 +529,8 @@ int HTTP1_DiscardReqBody(struct req *req) { + if (req->req_body_status == REQ_BODY_DONE) + return(0); return(HTTP1_IterateReqBody(req, httpq_req_body_discard, NULL)); } @@ -554,31 +543,24 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) { struct storage *st; ssize_t l; - int i; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (req->req_body_status == REQ_BODY_CACHED) + switch(req->req_body_status) { + case REQ_BODY_CACHED: + case REQ_BODY_NONE: return (0); - - if (req->req_body_status == REQ_BODY_NONE) - return (0); - - if (req->req_body_status != REQ_BODY_INIT) - return (-1); - - i = http1_setup_req_body(req); - if (i < 0) - return (i); + case REQ_BODY_PRESENT: + break; + default: + WRONG("Wrong req_body_status in HTTP1_CacheReqBody()"); + } if (req->req_bodybytes > maxsize) { req->req_body_status = REQ_BODY_FAIL; return (-1); } - if (req->req_body_status == REQ_BODY_NONE) - return (0); - st = NULL; do { if (st == NULL) { diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d7ab8f8..81be78e 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -79,7 +79,7 @@ const char * reqbody_status_2str(enum req_body_state_e e) { switch (e) { -#define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U); break; +#define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U); #include "tbl/req_body.h" #undef REQ_BODY default: From phk at varnish-cache.org Mon Jul 8 09:50:53 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 08 Jul 2013 11:50:53 +0200 Subject: [master] 69e6872 Add a per session mutex, there are now things we do in parallel which will need this. Message-ID: commit 69e6872bd2ae020196258f0ff78b3f9d748ab60b Author: Poul-Henning Kamp Date: Mon Jul 8 09:49:50 2013 +0000 Add a per session mutex, there are now things we do in parallel which will need this. We may need to improve MPL or LCK to cope with this. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fbf0989..b673eb1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -709,6 +709,7 @@ struct sess { #define SESS_MAGIC 0x2c2f9c5a enum sess_step sess_step; + struct lock mtx; int fd; enum sess_close reason; uint32_t vxid; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index f117459..8d80160 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -102,6 +102,7 @@ ses_setup(struct sess *sp) sp->sockaddr.ss_family = sp->mysockaddr.ss_family = PF_UNSPEC; sp->t_open = NAN; sp->t_idle = NAN; + Lck_New(&sp->mtx, lck_sess); } /*-------------------------------------------------------------------- @@ -332,6 +333,7 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now) b->pipe, b->pass, b->fetch, b->hdrbytes, b->bodybytes); VSL(SLT_End, sp->vxid, "%s", ""); + Lck_Delete(&sp->mtx); MPL_Free(pp->mpl_sess, sp); } diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 68077ce..8329bab 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -37,6 +37,7 @@ LOCK(hcb) LOCK(hcl) LOCK(vcl) LOCK(sessmem) +LOCK(sess) LOCK(wstat) LOCK(herder) LOCK(wq) From phk at varnish-cache.org Mon Jul 8 12:33:57 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 08 Jul 2013 14:33:57 +0200 Subject: [master] dd90a88 Minimal locking to prevent two backend fetches from trying to get at uncached req.body at the same time. Message-ID: commit dd90a88b1c64b5880f2c4fcd83d3a8d3973d182c Author: Poul-Henning Kamp Date: Mon Jul 8 12:33:26 2013 +0000 Minimal locking to prevent two backend fetches from trying to get at uncached req.body at the same time. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b673eb1..eaaffb7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -620,7 +620,7 @@ struct req { enum req_step req_step; VTAILQ_ENTRY(req) w_list; - enum req_body_state_e req_body_status; + volatile enum req_body_state_e req_body_status; struct storagehead body; struct { diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index d4a296a..9f150ea 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -490,9 +490,27 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) return (0); case REQ_BODY_PRESENT: break; + case REQ_BODY_DONE: + case REQ_BODY_TAKEN: + VSLb(req->vsl, SLT_VCL_Error, + "Uncached req.body can only be consumed once."); + return (-1); default: WRONG("Wrong req_body_status in HTTP1_IterateReqBody()"); } + Lck_Lock(&req->sp->mtx); + if (req->req_body_status == REQ_BODY_PRESENT) { + req->req_body_status = REQ_BODY_TAKEN; + i = 0; + } else + i = -1; + Lck_Unlock(&req->sp->mtx); + if (i) { + VSLb(req->vsl, SLT_VCL_Error, + "Multiple attempts to access non-cached req.body"); + return (i); + } + do { l = http1_iter_req_body(req, buf, sizeof buf); if (l < 0) { @@ -531,11 +549,16 @@ HTTP1_DiscardReqBody(struct req *req) if (req->req_body_status == REQ_BODY_DONE) return(0); + if (req->req_body_status == REQ_BODY_TAKEN) + return(0); return(HTTP1_IterateReqBody(req, httpq_req_body_discard, NULL)); } /*---------------------------------------------------------------------- * Cache the req.body if it is smaller than the given size + * + * This function must be called before any backend fetches are kicked + * off to prevent parallelism. */ int diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 3009e90..c63be80 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -494,6 +494,11 @@ VRT_CacheReqBody(const struct vrt_ctx *ctx, long long maxsize) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + if (ctx->method != VCL_MET_RECV) { + VSLb(ctx->vsl, SLT_VCL_Error, + "req.body can only be cached in vcl_recv{}"); + return (0); + } return (HTTP1_CacheReqBody(ctx->req, maxsize)); } From phk at varnish-cache.org Mon Jul 8 12:43:40 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 08 Jul 2013 14:43:40 +0200 Subject: [master] cef7f39 Forgot this bit Message-ID: commit cef7f39ec262c5dca78658ac3f319f1c159b9346 Author: Poul-Henning Kamp Date: Mon Jul 8 12:43:33 2013 +0000 Forgot this bit diff --git a/include/tbl/req_body.h b/include/tbl/req_body.h index b6602cb..a649bf2 100644 --- a/include/tbl/req_body.h +++ b/include/tbl/req_body.h @@ -31,6 +31,7 @@ REQ_BODY(INIT) REQ_BODY(PRESENT) +REQ_BODY(TAKEN) REQ_BODY(CACHED) REQ_BODY(DONE) REQ_BODY(FAIL) From phk at varnish-cache.org Mon Jul 15 08:26:01 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 15 Jul 2013 10:26:01 +0200 Subject: [master] 65c8593 Fix boundary condition on an assert. Message-ID: commit 65c8593dc828b0ac6944d3897cf33d64028c6c43 Author: Poul-Henning Kamp Date: Mon Jul 15 08:25:19 2013 +0000 Fix boundary condition on an assert. Fixes #1324 diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 43b4872..290909f 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -118,6 +118,7 @@ vmod_hash_backend(const struct vrt_ctx *ctx, struct vmod_directors_hash *rr, r = vbe32dec(sha256); r = scalbn(r, -32); + assert(r >= 0 && r <= 1.0); be = vdir_pick_be(rr->vd, ctx->bo, r, rr->nloops); return (be); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index a8dd8a7..6d2be1e 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -67,6 +67,7 @@ vmod_rr_getfd(const struct director *dir, struct busyobj *bo) CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); r = scalbn(random(), -31); + assert(r >= 0 && r < 1.0); be = vdir_pick_be(rr->vd, bo, r, rr->nloops); if (be == NULL) return (NULL); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 62b0033..14d523d 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -180,7 +180,7 @@ vdir_pick_be(struct vdir *vd, const struct busyobj *bo, double w, tw = vd->total_weight; nbe = vd->n_backend; - assert(w >= 0.0 && w <= 1.0); + assert(w >= 0.0 && w < 1.0); vdir_lock(vd); for (l = 0; nbe > 0 && tw > 0.0 && l commit adf3f128e661bd5d7a55edcb30a3b964c18b1a7a Author: Poul-Henning Kamp Date: Mon Jul 15 08:38:03 2013 +0000 Report the right token in the error message. Fixes #1322 diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 697de15..a8c20b5 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -54,8 +54,6 @@ varnish v1 -errvcl {Unused sub foo, defined:} { sub foo { } } - - varnish v1 -errvcl {Invalid return "deliver"} { backend b { .host = "127.0.0.1"; } @@ -67,3 +65,15 @@ varnish v1 -errvcl {Invalid return "deliver"} { return (deliver); } } + +varnish v1 -errvcl {directors are now in VMOD.directors} { + backend b { .host = "127.0.0.1"; } + + director d1 random { + .backend b; + } + + sub vcl_recv { + set req.backend = d1; + } +} diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index d5f216e..09604cb 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -658,12 +658,11 @@ vcc_ParseDirector(struct vcc *tl) isfirst = tl->ndirector; if (vcc_IdIs(t_first, "backend")) { - tl->t_policy = t_first; vcc_ParseSimpleDirector(tl); } else { VSB_printf(tl->sb, "\ndirectors are now in VMOD.directors\n"); - vcc_ErrWhere(tl, tl->t_policy); + vcc_ErrWhere(tl, t_first); return; } if (tl->err) { @@ -678,6 +677,5 @@ vcc_ParseDirector(struct vcc *tl) tl->t_defaultdir = tl->t_dir; } - tl->t_policy = NULL; tl->t_dir = NULL; } diff --git a/lib/libvcl/vcc_compile.h b/lib/libvcl/vcc_compile.h index 64b5995..feb993a 100644 --- a/lib/libvcl/vcc_compile.h +++ b/lib/libvcl/vcc_compile.h @@ -191,7 +191,6 @@ struct vcc { int defaultdir; struct token *t_defaultdir; struct token *t_dir; - struct token *t_policy; unsigned unique; unsigned nvmodpriv; From apj at varnish-cache.org Mon Jul 15 10:52:12 2013 From: apj at varnish-cache.org (Andreas Plesner Jacobsen) Date: Mon, 15 Jul 2013 12:52:12 +0200 Subject: [master] d0c0ee9 Remove invalid example Message-ID: commit d0c0ee9bebb85cf127aa0203e8a78db0549b9efb Author: Andreas Plesner Jacobsen Date: Mon Jul 15 12:51:56 2013 +0200 Remove invalid example diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index ef0c5eb..2411368 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -300,11 +300,6 @@ Simple example: All requests where req.url exactly matches the string req.url == "/news" -Example: Ban all documents where the name does not end with ".ogg", -and where the size of the object is greater than 10 megabytes:: - - req.url !~ "\.ogg$" && obj.size > 10MB - Example: Ban all documents where the serving host is "example.com" or "www.example.com", and where the Set-Cookie header received from the backend contains "USERID=1663":: From tfheen at varnish-cache.org Mon Jul 22 07:35:08 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Jul 2013 09:35:08 +0200 Subject: [master] 1916914 Fix up std.syslog example Message-ID: commit 1916914d41e14913a00c822d3f8fef3b52d32a12 Author: Tollef Fog Heen Date: Mon Jul 22 09:33:53 2013 +0200 Fix up std.syslog example Thanks to InvertedAcceleration for a patch that pointed me at documentation that needed improving. diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 984331e..f8c4456 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -95,9 +95,10 @@ Prototype Return value Void Description - Logs *string* to syslog marked with *priority*. + Logs *string* to syslog marked with *priority*. See your + system's syslog.h file for the legal values of *priority*. Example - std.syslog( LOG_USER|LOG_ALERT, "There is serious troble"); + std.syslog(8 + 1, "Something is wrong"); fileread -------- From tfheen at varnish-cache.org Mon Jul 22 11:28:26 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Jul 2013 13:28:26 +0200 Subject: [master] b0c9d6f Stop printing to stdout on ESI parse warnings Message-ID: commit b0c9d6f4bab6b272e1c422abe3f7cbeefd8ed36d Author: Tollef Fog Heen Date: Mon Jul 22 13:25:38 2013 +0200 Stop printing to stdout on ESI parse warnings This looks like a bit of forgotten debugging, left by mistake. diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 6eac8d3..1b043a3 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -201,7 +201,6 @@ vep_warn(const struct vep_state *vep, const char *p) VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); - printf("WARNING at %jd %s\n", l, p); VSLb(vep->bo->vsl, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } From tfheen at varnish-cache.org Mon Jul 22 11:28:31 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 22 Jul 2013 13:28:31 +0200 Subject: [3.0] ec52648 Stop printing to stdout on ESI parse warnings Message-ID: commit ec52648a2b9e28cf226555f11b6dccc8aa847c82 Author: Tollef Fog Heen Date: Mon Jul 22 13:25:38 2013 +0200 Stop printing to stdout on ESI parse warnings This looks like a bit of forgotten debugging, left by mistake. diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c index ae45008..211a93a 100644 --- a/bin/varnishd/cache_esi_parse.c +++ b/bin/varnishd/cache_esi_parse.c @@ -201,7 +201,6 @@ vep_warn(const struct vep_state *vep, const char *p) VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); - printf("WARNING at %jd %s\n", l, p); WSP(vep->sp, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); } From martin at varnish-cache.org Mon Jul 22 14:06:55 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Mon, 22 Jul 2013 16:06:55 +0200 Subject: [3.0] 6672d25 Make the VSL error string on HTTP fetch timeout errors be 'http first read error' when tripping on first_byte_timeout, and 'http read error' when tripping on between_bytes_timeout (used to be 'http first read error' in both cases). This now matches current master. Message-ID: commit 6672d256e374d70a3e6b93f93ccf8f3b0e20938b Author: Martin Blix Grydeland Date: Mon Jul 22 16:01:25 2013 +0200 Make the VSL error string on HTTP fetch timeout errors be 'http first read error' when tripping on first_byte_timeout, and 'http read error' when tripping on between_bytes_timeout (used to be 'http first read error' in both cases). This now matches current master. diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c index de54da3..7b50c1e 100644 --- a/bin/varnishd/cache_fetch.c +++ b/bin/varnishd/cache_fetch.c @@ -498,7 +498,7 @@ FetchHdr(struct sess *sp) i = HTC_Rx(w->htc); if (i < 0) { WSP(sp, SLT_FetchError, - "http first read error: %d %d (%s)", + "http read error: %d %d (%s)", i, errno, strerror(errno)); VDI_CloseFd(sp); /* XXX: other cleanup ? */ From tfheen at varnish-cache.org Wed Jul 31 11:02:54 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 31 Jul 2013 13:02:54 +0200 Subject: [master] bca2da5 Adjust ulimit on RPM platforms Message-ID: commit bca2da56c94c0b472b667f0d1bcf2444d4ae6ff8 Author: Ingvar Hagelund Date: Wed Jul 31 13:02:18 2013 +0200 Adjust ulimit on RPM platforms The default number of processes/threads (ulimit -u) on rhel6 and clones is 1024, which is too little for varnish. This patch adds a variable NPROC to sysconfig/initscript suppport in the rpm package. If no value is set in sysconfig, it will be set to 10000. diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc index c2faa25..323024b 100755 --- a/redhat/varnish.initrc +++ b/redhat/varnish.initrc @@ -53,6 +53,9 @@ start() { # Open files (usually 1024, which is way too small for varnish) ulimit -n ${NFILES:-131072} + # Open processes/threads (usually 1024 on rhel6, which is too little for varnish) + ulimit -u ${NPROC:-10000} + # Varnish wants to lock shared memory log in memory. ulimit -l ${MEMLOCK:-82000} diff --git a/redhat/varnish.sysconfig b/redhat/varnish.sysconfig index f5846c9..b1b640c 100644 --- a/redhat/varnish.sysconfig +++ b/redhat/varnish.sysconfig @@ -7,6 +7,9 @@ # Maximum number of open files (for ulimit -n) NFILES=131072 +# Maximum number of processes/threads (for ulimit -u) +NPROC=10000 + # Locked shared memory (for ulimit -l) # Default log size is 82MB + header MEMLOCK=82000 From tfheen at varnish-cache.org Wed Jul 31 12:05:52 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 31 Jul 2013 14:05:52 +0200 Subject: [master] e70a252 Revert "Adjust ulimit on RPM platforms" Message-ID: commit e70a2527a96ea823590f599e8820fa3b1a414a1e Author: Tollef Fog Heen Date: Wed Jul 31 14:05:21 2013 +0200 Revert "Adjust ulimit on RPM platforms" Duplicate commit, already done by daghf in ebb667015cc531c2cdc11c709b67c09e75467275 This reverts commit bca2da56c94c0b472b667f0d1bcf2444d4ae6ff8. diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc index 323024b..c2faa25 100755 --- a/redhat/varnish.initrc +++ b/redhat/varnish.initrc @@ -53,9 +53,6 @@ start() { # Open files (usually 1024, which is way too small for varnish) ulimit -n ${NFILES:-131072} - # Open processes/threads (usually 1024 on rhel6, which is too little for varnish) - ulimit -u ${NPROC:-10000} - # Varnish wants to lock shared memory log in memory. ulimit -l ${MEMLOCK:-82000} diff --git a/redhat/varnish.sysconfig b/redhat/varnish.sysconfig index b1b640c..f5846c9 100644 --- a/redhat/varnish.sysconfig +++ b/redhat/varnish.sysconfig @@ -7,9 +7,6 @@ # Maximum number of open files (for ulimit -n) NFILES=131072 -# Maximum number of processes/threads (for ulimit -u) -NPROC=10000 - # Locked shared memory (for ulimit -l) # Default log size is 82MB + header MEMLOCK=82000