]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 27 Oct 2009 05:24:36 +0000 (18:24 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 27 Oct 2009 05:24:36 +0000 (18:24 +1300)
Polished ESI support

 * make libxml2 and libexpat parser modules pluggable (Henrik)
 * make libexpat and libxml2 tunable at configure time (Amos + Henrik)
 * Fix Bug 2794: ESI parsing fails on FreeBSD (Francesco Chemolli)
 * Enable ESI by default and auto-test

13 files changed:
configure.in
doc/release-notes/release-3.1.html
doc/release-notes/release-3.1.sgml
lib/libTrie/test/Makefile.am
src/Makefile.am
src/esi/ExpatParser.cc
src/esi/ExpatParser.h
src/esi/Expression.cc
src/esi/Libxml2Parser.cc
src/esi/Libxml2Parser.h
src/esi/Makefile.am
src/esi/Module.cc
test-suite/buildtests/layer-02-maximus.opts

index fc5a0b0130f33802583d2aee79d38958a76160d1..b0576a7ec4ca3607810e786fa791ddb9f0b96225 100644 (file)
@@ -831,34 +831,61 @@ AC_ARG_ENABLE(delay-pools,
 dnl disable generic/common adaptation support by default
 use_adaptation=no
 
-AM_CONDITIONAL(USE_ESI, false)
+use_esi=yes
 AC_ARG_ENABLE(esi,
-  AS_HELP_STRING([--enable-esi],[Enable ESI for accelerators. Requires libexpat.
-                  Enabling ESI will cause squid to follow the
-                  Edge Acceleration Specification (www.esi.org).
-                  This causes squid to IGNORE client Cache-Control headers.
-                  DO NOT use this in a squid configured as a web proxy, 
-                  ONLY use it in a squid configured for webserver acceleration.]),
+  AS_HELP_STRING([--enable-esi],[Enable ESI for accelerators. Benefits from libexpat or libxml2.
+                  Enabling ESI will cause squid reverse proxies to be capable of the
+                  Edge Acceleration Specification (www.esi.org).]),
              use_esi=$enableval, use_esi=no)
+HAVE_LIBEXPAT=0
+EXPATLIB=
+HAVE_LIBXML2=0
+XMLLIB=
 if test "$use_esi" = "yes" ; then
+  AC_MSG_NOTICE([Enabling ESI processor and Surrogate header support.])
   AC_DEFINE(USE_SQUID_ESI,1,[Compile the ESI processor and Surrogate header support])
-  AM_CONDITIONAL(USE_ESI, true)
 
-  dnl Perform configuration consistency checks for ESI
-  dnl ESI support requires libexpat
-  AC_CHECK_LIB([expat], [main],
-        [ESI_LIBS="-lexpat"],
-        [AC_MSG_FAILURE([ESI support requires libexpat library, but no usable library was found])]
-  )
-  AC_CHECK_LIB([xml2], [main],
-        [ESI_LIBS="-lxml2"],
-        [AC_MSG_FAILURE([ESI support requires libxml2 library, but no usable library was found])]
-  )
-  XTRA_LIBS="$XTRA_LIBS -lexpat -lxml2"
+  AC_ARG_WITH(expat, AS_HELP_STRING([--without-libexpat],[Do not use libexpat for ESI. Default: auto-detect]))
+  if test "$with_expat" != "no" ; then
+    AC_CHECK_LIB([expat], [main], [EXPATLIB="-lexpat"; HAVE_LIBEXPAT=1])
+    AC_CHECK_HEADERS([expat.h])
+    AC_DEFINE_UNQUOTED(HAVE_LIBEXPAT, $HAVE_LIBEXPAT, [Define to 1 if you have the expat library])
+    if test "$with_expat" = "yes" && test "$HAVE_LIBEXPAT" != "1" ; then
+      AC_MSG_ERROR([Required library libexpat is not able to be found.])
+    fi
+  fi
+
+  AC_ARG_WITH(xml2, AS_HELP_STRING([--without-libxml2],[Do not use libxml2 for ESI. Default: auto-detect]))
+  if test "$with_xml2" != "no" ; then
+    AC_CHECK_LIB([xml2], [main], [XMLLIB="-lxml2"; HAVE_LIBXML2=1])
+    dnl Find the main header and include path...
+    AC_CHECK_HEADERS([libxml/parser.h], [], [
+        SAVED_CPPFLAGS="$CPPFLAGS"
+        CPPFLAGS="-I/usr/include/libxml2 $CPPFLAGS"
+        unset ac_cv_header_libxml_parser_h
+        AC_CHECK_HEADERS([libxml/parser.h], [ac_cv_libxml2_include=yes], [])
+        CPPFLAGS="$SAVED_CPPFLAGS"
+        ])
+    if test "x$ac_cv_libxml2_include" = "xyes"; then
+        SQUID_CXXFLAGS="-I/usr/include/libxml2 $SQUID_CXXFLAGS"
+        CPPFLAGS="-I/usr/include/libxml2 $CPPFLAGS"
+    fi
+    dnl Now that we know where to look find the other headers...
+    AC_CHECK_HEADERS(libxml/HTMLparser.h libxml/HTMLtree.h)
+    AC_DEFINE_UNQUOTED(HAVE_LIBXML2, $HAVE_LIBXML2, [Define to 1 if you have the libxml2 library])
+    if test "$with_xml2" = "yes" && test "$HAVE_LIBXML2" != "1" ; then
+      AC_MSG_ERROR([Required library libxml2 is not able to be found.])
+    fi
+  fi
 
 else
-  AC_DEFINE(USE_SQUID_ESI,0,[Compile the ESI processor and Surrogate header support])
+  AC_MSG_NOTICE([Disabling ESI processor and Surrogate header support.])
 fi
+AM_CONDITIONAL(USE_ESI, test "$use_esi" = "yes")
+AM_CONDITIONAL(HAVE_LIBEXPAT, test $HAVE_LIBEXPAT = 1)
+AC_SUBST(EXPATLIB)
+AM_CONDITIONAL(HAVE_LIBXML2, test $HAVE_LIBXML2 = 1)
+AC_SUBST(XMLLIB)
 
 AM_CONDITIONAL(USE_ICAP_CLIENT, false)
 AC_ARG_ENABLE(icap-client,
@@ -2244,17 +2271,6 @@ AC_CHECK_HEADERS( \
 ,,,
 SQUID_BSDNET_INCLUDES)
 
-AC_CHECK_HEADERS([libxml/parser.h], [], [
-       SAVED_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="-I/usr/include/libxml2 $CPPFLAGS"
-       unset ac_cv_header_libxml_parser_h
-       AC_CHECK_HEADERS([libxml/parser.h], [ac_cv_libxml2_include=yes], [])
-       CPPFLAGS="$SAVED_CPPFLAGS"
-       ])
-if test "x$ac_cv_libxml2_include" = "xyes"; then
-       SQUID_CXXFLAGS="-I/usr/include/libxml2 $SQUID_CXXFLAGS"
-fi
-
 AC_C_CONST
 AC_C_BIGENDIAN
 
index e1812a173732f21f49fa46623c9faa5efd9a7177..65f20f2a3e7c2215f5f7e5eca82f47964d93d10d 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <HTML>
 <HEAD>
- <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.50">
+ <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.65">
  <TITLE>Squid 3.1.0.13 release notes</TITLE>
 </HEAD>
 <BODY>
@@ -1740,6 +1740,18 @@ check the CNAME-Only Requests statistics squid maintains.</P>
 <P>If it produces ongoing serious problems the external helper may be needed
 but please report the bugs anyway.</P>
 
+<DT><B>--with-libexpat / --without-libexpat</B><DD>
+<P>Require libexpat XML parser to be built into Squid for ESI parsing.
+Build will fail if this option is used and the library is not present.
+Default is to auto-detect it when using ESI and ignore if not present.
+Use --without-libexpat to prevent it being auto-detected.</P>
+
+<DT><B>--with-libxml2 / --without-libxml2</B><DD>
+<P>Require libxml2 XML parser to be built into Squid for ESI parsing.
+Build will fail if this option is used and the library is not present.
+Default is to auto-detect it when building with ESI.
+Use --without-libxml2 to prevent it being auto-detected.</P>
+
 <DT><B>--with-logdir=PATH</B><DD>
 <P>Allow build-time configuration of Default location for squid logs.</P>
 
index 0d480f8bb16ef015c749f11c20e21fe2d3acca70..295a759fe760a829cca2dac4a8dfcdd454ef419f 100644 (file)
@@ -1491,6 +1491,18 @@ This section gives an account of those changes in three categories:
        <p>If it produces ongoing serious problems the external helper may be needed
           but please report the bugs anyway.
 
+       <tag>--with-libexpat / --without-libexpat</tag>
+       <p>Require libexpat XML parser to be built into Squid for ESI parsing.
+          Build will fail if this option is used and the library is not present.
+          Default is to auto-detect it when using ESI and ignore if not present.
+          Use --without-libexpat to prevent it being auto-detected.
+
+       <tag>--with-libxml2 / --without-libxml2</tag>
+       <p>Require libxml2 XML parser to be built into Squid for ESI parsing.
+          Build will fail if this option is used and the library is not present.
+          Default is to auto-detect it when building with ESI.
+          Use --without-libxml2 to prevent it being auto-detected.
+
        <tag>--with-logdir=PATH</tag>
        <p>Allow build-time configuration of Default location for squid logs.
 
index abb8cad137fc12da0ee1d1d10e51b0a219e4bb0f..45f88fea5839504b26a18b465a44b699c5837480 100644 (file)
@@ -11,4 +11,4 @@ trie_SOURCES = trie.cc
 trie_LDADD = $(top_builddir)/src/libTrie.a
 
 trie_c_SOURCES = trie-c.c
-trie_c_LDADD = $(top_builddir)/src/libTrie.a -lstdc++
+trie_c_LDADD = $(top_builddir)/src/libTrie.a -lstdc++ -lm
index 39d8006f3ec33d749d3a674d63239d66835894f8..6b2ba23f1485b10d19f5426b5a06c1aa11fe2cf4 100644 (file)
@@ -44,9 +44,12 @@ ADAPTATION_LIBS = @ADAPTATION_LIBS@
 
 if USE_ESI
 SUBDIRS += esi
-ESI_LIBS = \
+ESI_LOCAL_LIBS = \
        esi/libesi.la \
        $(top_builddir)/lib/libTrie/src/libTrie.a
+ESI_LIBS = $(ESI_LOCAL_LIBS) \
+       @XMLLIB@ \
+       @EXPATLIB@
 else
 ESI_LIBS = 
 endif
@@ -527,7 +530,7 @@ squid_LDADD = \
        @REGEXLIB@ \
        @SNMPLIB@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @SSLLIB@ \
        -lmiscutil \
        @XTRA_LIBS@ \
@@ -539,7 +542,7 @@ squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
        @REPL_OBJS@ \
        @SNMPLIB@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LOCAL_LIBS) \
        $(COMMON_LIBS)
 
 if USE_LOADABLE_MODULES
@@ -1174,7 +1177,7 @@ tests_testCacheManager_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1345,7 +1348,7 @@ tests_testEvent_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1493,7 +1496,7 @@ tests_testEventLoop_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1636,7 +1639,7 @@ tests_test_http_range_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1784,7 +1787,7 @@ tests_testHttpRequest_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -2136,7 +2139,7 @@ tests_testURL_LDADD = \
        @REGEXLIB@ \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
-       ${ESI_LIBS} \
+       $(ESI_LIBS) \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
        @SQUID_CPPUNIT_LIBS@ \
index 6bdb0fd9c182b65a415fc59753f8203fef192063..3019af08ec8d1e55622f4fe6cf042493becc01f0 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "squid.h"
 
-#if USE_SQUID_ESI
+#if USE_SQUID_ESI && HAVE_LIBEXPAT
 
 #include "esi/ExpatParser.h"
 
index dfc5045a514190ce517a5be0206ed2791b17114e..76246d75fb318c8eabb13e8b4bb4ee4356cb5459 100644 (file)
 #ifndef SQUID_ESIEXPATPARSER_H
 #define SQUID_ESIEXPATPARSER_H
 
-#if USE_SQUID_ESI
+#include "config.h"
+
+#if USE_SQUID_ESI && HAVE_LIBEXPAT
 
 #include "esi/Parser.h"
+
+#if HAVE_EXPAT_H
 #include <expat.h>
+#endif
 
 class ESIExpatParser : public ESIParser
 {
index 759171842d1ca7884b5bf04cfc7f452e6324b1f3..012790391bca18a955fb3a05b45d95be572afe36 100644 (file)
@@ -714,6 +714,7 @@ getsymbol (const char *s, char const **endptr)
 
         if ((point = strchr (s, '.')) && point - s < (ssize_t)length) {
             /* floating point */
+            errno=0; /* reset errno */
             rv.value.floating = strtod (s, &end);
 
             if (s == end || errno) {
@@ -730,6 +731,7 @@ getsymbol (const char *s, char const **endptr)
             }
         } else {
             /* INT */
+            errno=0; /* reset errno */
             rv.value.integral = strtol (s, &end, 0);
 
             if (s == end || errno) {
index e0fc3562cc4740707d0a0d6134e713970fa43206..8f1a7faa6a861049afcb85d49d0a3453e64e5b52 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "squid.h"
 
-#if USE_SQUID_ESI
+#if USE_SQUID_ESI && HAVE_LIBXML2
 
 #include "esi/Libxml2Parser.h"
 
index c360930bb9589dcfdf1ef33200a789dcf3cce248..1dd093983e81ed2abaaf4a9f185ad79d38dd91e8 100644 (file)
@@ -40,7 +40,9 @@
 #ifndef SQUID_ESILIBXML2PARSER_H
 #define SQUID_ESILIBXML2PARSER_H
 
-#if USE_SQUID_ESI
+#include "config.h"
+
+#if USE_SQUID_ESI && HAVE_LIBXML2
 
 #include "esi/Parser.h"
 // workaround for definition of "free" that prevents include of
 #define OLD_FREE free
 #undef free
 #endif
+#if HAVE_LIBXML_PARSER_H
 #include <libxml/parser.h>
+#endif
+#if HAVE_LIBXML_HTMLPARSER_H
 #include <libxml/HTMLparser.h>
+#endif
+#if HAVE_LIBXML_HTMLTREE_H
 #include <libxml/HTMLtree.h>
+#endif
 
 #ifdef OLD_FREE
 #define free OLD_FREE
index bbd58b7ed6c87ae6e5a4bd0ab8c5c183d6027850..8158a45b8d222cda1905e128debae329efb88fc9 100644 (file)
@@ -3,28 +3,39 @@ include $(top_srcdir)/src/TestHeaders.am
 
 noinst_LTLIBRARIES = libesi.la
 
+ESI_PARSER_SOURCES = \
+       CustomParser.cc \
+       CustomParser.h
+
+if HAVE_LIBEXPAT
+ESI_PARSER_SOURCES += \
+       ExpatParser.cc \
+       ExpatParser.h
+endif
+
+if HAVE_LIBXML2
+ESI_PARSER_SOURCES += \
+       Libxml2Parser.cc \
+       Libxml2Parser.h
+endif
+
 libesi_la_SOURCES = \
        Assign.cc \
        Assign.h \
        Attempt.h \
        Context.cc \
        Context.h \
-       CustomParser.cc \
-       CustomParser.h \
+       $(ESI_PARSER_SOURCES) \
        Element.h \
        ElementList.h \
        Esi.cc \
        Esi.h \
        Except.h \
-       ExpatParser.cc \
-       ExpatParser.h \
        Expression.cc \
        Expression.h \
        Include.cc \
        Include.h \
        Literal.h \
-       Libxml2Parser.cc \
-       Libxml2Parser.h \
        Module.cc \
        Module.h \
        Parser.cc \
index 5d7b71875e4bce4ce25f2d2895fb27b5943041d3..71b9be035eaa2bf8b6b2c313f6d6bb83bbb6dcc7 100644 (file)
@@ -5,26 +5,42 @@
 #include "esi/ExpatParser.h" /* must follow esi/Libxml2Parser.h */
 
 static ESIParser::Register *prCustom = 0;
+#if HAVE_LIBXML2
 static ESIParser::Register *prLibxml = 0;
+#endif
+#if HAVE_LIBEXPAT
 static ESIParser::Register *prExpat = 0;
+#endif
 
 void Esi::Init()
 {
     assert(!prCustom); // we should be called once
+
     prCustom = new ESIParser::Register("custom", &ESICustomParser::NewParser);
+
+#if HAVE_LIBXML2
     prLibxml = new ESIParser::Register("libxml2", &ESILibxml2Parser::NewParser);
+#endif
+
+#if HAVE_LIBEXPAT
     prExpat = new ESIParser::Register("expat", &ESIExpatParser::NewParser);
+#endif
 }
 
 void Esi::Clean()
 {
     assert(prCustom); // we should be called once, and only after Init()
 
+#if HAVE_LIBEXPAT
     delete prExpat;
-    delete prLibxml;
-    delete prCustom;
-
     prExpat = NULL;
+#endif
+
+#if HAVE_LIBXML2
+    delete prLibxml;
     prLibxml = NULL;
+#endif
+
+    delete prCustom;
     prCustom = NULL;
 }
index ca311846b77f561b4d082edeb52c267cdccfe642..fb68aaea9b7df52b148da4235d83a60a24aefc9e 100644 (file)
@@ -36,7 +36,6 @@ MAKETEST="distcheck"
 #   --enable-ecap \
 #   --enable-epoll \
 #   --enable-kqueue \
-#   --enable-esi \
 #   --enable-win32-service \
 #
 #
@@ -96,6 +95,7 @@ OPTS=" \
        --enable-auto-locale \
        --enable-translation \
        --enable-zph-qos \
+       --enable-esi \
  \
        --with-aio \
        --with-build-environment=default \