diff -u -r -N squid-3.2.0.16/ChangeLog squid-3.2.0.17/ChangeLog --- squid-3.2.0.16/ChangeLog 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/ChangeLog 2012-04-13 01:43:26.000000000 +1200 @@ -1,3 +1,15 @@ +Changes to squid-3.2.0.17 (12 Apr 2011): + + - Bug 3527: EUI compile errors on Mac OS X 10.5.8 PPC + - Bug 3509: kQueue compile error + - Bug 3505: crash in CbcPointer constructor + - Bug 3441: Part 3: Replace corrupted v1 swap.state with new v2 format. + - Bug 3397: do not mark connection as opened until after SYN-ACK + - Bug 3193: NTLM decoder truncating strings + - Windows FD handling polish and some fixes + - Solaris 9/10 various build fixes + - ... and some more code polish + Changes to squid-3.2.0.16 (07 Mar 2011): - Bug 3508: Correct DNS timeout handling. diff -u -r -N squid-3.2.0.16/compat/compat_shared.h squid-3.2.0.17/compat/compat_shared.h --- squid-3.2.0.16/compat/compat_shared.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/compat/compat_shared.h 2012-04-13 01:43:26.000000000 +1200 @@ -257,9 +257,4 @@ #define PRINTF_FORMAT_ARG3 #endif -/* NULL is not always provided. */ -#ifndef NULL -#define NULL ((void *)0) -#endif - #endif /* _SQUID_COMPAT_SHARED_H */ diff -u -r -N squid-3.2.0.16/compat/os/solaris.h squid-3.2.0.17/compat/os/solaris.h --- squid-3.2.0.16/compat/os/solaris.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/compat/os/solaris.h 2012-04-13 01:43:26.000000000 +1200 @@ -4,7 +4,6 @@ #if _SQUID_SOLARIS_ - /* * ugly hack. System headers require wcsstr, but don't define it. */ @@ -85,6 +84,16 @@ #include "compat/os/opensolaris_10_netdb.h" #endif +/* Solaris 10 lacks SUN_LEN */ +#if !defined(SUN_LEN) +#define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + +/* Soaris 10 does not define POSIX AF_LOCAL, but does define the Unix name */ +#if !defined(AF_LOCAL) +#define AF_LOCAL AF_UNIX +#endif + /* Solaris lacks paths.h by default */ #if HAVE_PATHS_H #include @@ -93,5 +102,8 @@ #define _PATH_DEVNULL "/dev/null" #endif +/* Solaris 10 does not define strsep() */ +#include "compat/strsep.h" + #endif /* _SQUID_SOLARIS_ */ #endif /* SQUID_OS_SOALRIS_H */ diff -u -r -N squid-3.2.0.16/configure squid-3.2.0.17/configure --- squid-3.2.0.16/configure 2012-03-07 15:47:32.000000000 +1300 +++ squid-3.2.0.17/configure 2012-04-13 01:47:04.000000000 +1200 @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Revision. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.2.0.16. +# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.2.0.17. # # Report bugs to . # @@ -575,8 +575,8 @@ # Identity of this package. PACKAGE_NAME='Squid Web Proxy' PACKAGE_TARNAME='squid' -PACKAGE_VERSION='3.2.0.16' -PACKAGE_STRING='Squid Web Proxy 3.2.0.16' +PACKAGE_VERSION='3.2.0.17' +PACKAGE_STRING='Squid Web Proxy 3.2.0.17' PACKAGE_BUGREPORT='http://www.squid-cache.org/bugs/' PACKAGE_URL='' @@ -1570,7 +1570,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Squid Web Proxy 3.2.0.16 to adapt to many kinds of systems. +\`configure' configures Squid Web Proxy 3.2.0.17 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1640,7 +1640,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Squid Web Proxy 3.2.0.16:";; + short | recursive ) echo "Configuration of Squid Web Proxy 3.2.0.17:";; esac cat <<\_ACEOF @@ -2018,7 +2018,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Squid Web Proxy configure 3.2.0.16 +Squid Web Proxy configure 3.2.0.17 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -3114,7 +3114,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Squid Web Proxy $as_me 3.2.0.16, which was +It was created by Squid Web Proxy $as_me 3.2.0.17, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3933,7 +3933,7 @@ # Define the identity of the package. PACKAGE='squid' - VERSION='3.2.0.16' + VERSION='3.2.0.17' cat >>confdefs.h <<_ACEOF @@ -30632,7 +30632,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Squid Web Proxy $as_me 3.2.0.16, which was +This file was extended by Squid Web Proxy $as_me 3.2.0.17, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -30698,7 +30698,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Squid Web Proxy config.status 3.2.0.16 +Squid Web Proxy config.status 3.2.0.17 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -u -r -N squid-3.2.0.16/configure.ac squid-3.2.0.17/configure.ac --- squid-3.2.0.16/configure.ac 2012-03-07 15:47:31.000000000 +1300 +++ squid-3.2.0.17/configure.ac 2012-04-13 01:47:04.000000000 +1200 @@ -3,7 +3,7 @@ dnl dnl dnl -AC_INIT([Squid Web Proxy],[3.2.0.16],[http://www.squid-cache.org/bugs/],[squid]) +AC_INIT([Squid Web Proxy],[3.2.0.17],[http://www.squid-cache.org/bugs/],[squid]) AC_PREREQ(2.61) AC_CONFIG_HEADERS([include/autoconf.h]) AC_CONFIG_AUX_DIR(cfgaux) diff -u -r -N squid-3.2.0.16/contrib/Makefile.am squid-3.2.0.17/contrib/Makefile.am --- squid-3.2.0.16/contrib/Makefile.am 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/contrib/Makefile.am 2012-04-13 01:43:26.000000000 +1200 @@ -21,7 +21,8 @@ nextstep/info.in \ nextstep/makepkg \ nextstep/post_install \ - nextstep/pre_install + nextstep/pre_install \ + solaris/solaris-krb5-include.patch all: diff -u -r -N squid-3.2.0.16/contrib/Makefile.in squid-3.2.0.17/contrib/Makefile.in --- squid-3.2.0.16/contrib/Makefile.in 2012-03-07 15:45:28.000000000 +1300 +++ squid-3.2.0.17/contrib/Makefile.in 2012-04-13 01:45:24.000000000 +1200 @@ -284,7 +284,8 @@ nextstep/info.in \ nextstep/makepkg \ nextstep/post_install \ - nextstep/pre_install + nextstep/pre_install \ + solaris/solaris-krb5-include.patch all: all-am diff -u -r -N squid-3.2.0.16/contrib/solaris/solaris-krb5-include.patch squid-3.2.0.17/contrib/solaris/solaris-krb5-include.patch --- squid-3.2.0.16/contrib/solaris/solaris-krb5-include.patch 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/contrib/solaris/solaris-krb5-include.patch 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,19 @@ +--- /usr/include/kerberosv5/krb5.h.orig Mon Aug 23 04:09:23 2010 ++++ /usr/include/kerberosv5/krb5.h Mon Aug 23 04:10:53 2010 +@@ -171,6 +171,7 @@ + #define KRB5INT_END_DECLS + #endif + #endif ++KRB5INT_BEGIN_DECLS + + #if TARGET_OS_MAC + # pragma options align=mac68k +@@ -3246,8 +3247,4 @@ + /* for compatibility with older versions... */ + #define asn1_err_base ERROR_TABLE_BASE_asn1 + +-#ifdef __cplusplus +-} +-#endif +- + #endif /* _KRB5_H */ diff -u -r -N squid-3.2.0.16/helpers/basic_auth/DB/basic_db_auth.8 squid-3.2.0.17/helpers/basic_auth/DB/basic_db_auth.8 --- squid-3.2.0.16/helpers/basic_auth/DB/basic_db_auth.8 2012-03-07 17:08:46.000000000 +1300 +++ squid-3.2.0.17/helpers/basic_auth/DB/basic_db_auth.8 2012-04-13 02:44:59.000000000 +1200 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "BASIC_DB_AUTH 1" -.TH BASIC_DB_AUTH 1 "2012-03-06" "perl v5.10.1" "User Contributed Perl Documentation" +.TH BASIC_DB_AUTH 1 "2012-04-12" "perl v5.10.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff -u -r -N squid-3.2.0.16/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 squid-3.2.0.17/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 --- squid-3.2.0.16/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 2012-03-07 17:08:56.000000000 +1300 +++ squid-3.2.0.17/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 2012-04-13 02:45:14.000000000 +1200 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "EXT_WBINFO_GROUP_ACL.PL.IN 1" -.TH EXT_WBINFO_GROUP_ACL.PL.IN 1 "2012-03-06" "perl v5.10.1" "User Contributed Perl Documentation" +.TH EXT_WBINFO_GROUP_ACL.PL.IN 1 "2012-04-12" "perl v5.10.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff -u -r -N squid-3.2.0.16/include/version.h squid-3.2.0.17/include/version.h --- squid-3.2.0.16/include/version.h 2012-03-07 15:47:32.000000000 +1300 +++ squid-3.2.0.17/include/version.h 2012-04-13 01:47:04.000000000 +1200 @@ -9,7 +9,7 @@ */ #ifndef SQUID_RELEASE_TIME -#define SQUID_RELEASE_TIME 1331088172 +#define SQUID_RELEASE_TIME 1334238203 #endif #ifndef APP_SHORTNAME diff -u -r -N squid-3.2.0.16/lib/ntlmauth/ntlmauth.cc squid-3.2.0.17/lib/ntlmauth/ntlmauth.cc --- squid-3.2.0.16/lib/ntlmauth/ntlmauth.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/lib/ntlmauth/ntlmauth.cc 2012-04-13 01:43:26.000000000 +1200 @@ -95,7 +95,7 @@ if ((int32_t)le32toh(hdr->type) != type) { /* don't report this error - it's ok as we do a if() around this function */ -// fprintf(stderr, "ntlmCheckHeader: type is %d, wanted %d\n", le32toh(hdr->type), type); + debug("ntlm_validate_packet: type is %d, wanted %d\n", le32toh(hdr->type), type); return NTLM_ERR_PROTOCOL; } return NTLM_ERR_NONE; @@ -119,27 +119,26 @@ int32_t o; /* offset */ static char buf[NTLM_MAX_FIELD_LENGTH]; lstring rv; - unsigned short *s, c; - char *d, *sc; + char *d; lstring_zero(rv); l = le16toh(str->len); o = le32toh(str->offset); - /* debug("fetch_string(plength=%d,l=%d,o=%d)\n",packet_size,l,o); */ + // debug("ntlm_fetch_string(plength=%d,l=%d,o=%d)\n",packet_size,l,o); if (l < 0 || l > NTLM_MAX_FIELD_LENGTH || o + l > packet_size || o == 0) { - /* debug("ntlmssp: insane data (l: %d, o: %d)\n", l,o); */ + debug("ntlm_fetch_string: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", packet_size,l,o); return rv; } rv.str = (char *)packet + o; if ((flags & NTLM_NEGOTIATE_ASCII) == 0) { /* UNICODE string */ - s = (unsigned short *) ((char *) packet + o); + unsigned short *s = (unsigned short *)rv.str; rv.str = d = buf; for (l >>= 1; l; s++, l--) { - c = le16toh(*s); + unsigned short c = le16toh(*s); if (c > 254 || c == '\0') { fprintf(stderr, "ntlmssp: bad unicode: %04x\n", c); return rv; @@ -149,9 +148,9 @@ } } else { /* ASCII/OEM string */ - sc = (char *) packet + o; + char *sc = rv.str; - for (; l; l--) { + for (; l>=0; sc++, l--) { if (*sc == '\0' || !xisprint(*sc)) { fprintf(stderr, "ntlmssp: bad ascii: %04x\n", *sc); return rv; @@ -261,18 +260,23 @@ lstring rv; if (ntlm_validate_packet(&auth->hdr, NTLM_AUTHENTICATE)) { - fprintf(stderr, "ntlmDecodeAuth: header check fails\n"); + fprintf(stderr, "ntlm_unpack_auth: header check fails\n"); return NTLM_ERR_PROTOCOL; } - debug("ntlmDecodeAuth: size of %d\n", size); - debug("ntlmDecodeAuth: flg %08x\n", auth->flags); - debug("ntlmDecodeAuth: usr o(%d) l(%d)\n", auth->user.offset, auth->user.len); + debug("ntlm_unpack_auth: size of %d\n", size); + debug("ntlm_unpack_auth: flg %08x\n", auth->flags); + debug("ntlm_unpack_auth: lmr o(%d) l(%d)\n", le32toh(auth->lmresponse.offset), auth->lmresponse.len); + debug("ntlm_unpack_auth: ntr o(%d) l(%d)\n", le32toh(auth->ntresponse.offset), auth->ntresponse.len); + debug("ntlm_unpack_auth: dom o(%d) l(%d)\n", le32toh(auth->domain.offset), auth->domain.len); + debug("ntlm_unpack_auth: usr o(%d) l(%d)\n", le32toh(auth->user.offset), auth->user.len); + debug("ntlm_unpack_auth: wst o(%d) l(%d)\n", le32toh(auth->workstation.offset), auth->workstation.len); + debug("ntlm_unpack_auth: key o(%d) l(%d)\n", le32toh(auth->sessionkey.offset), auth->sessionkey.len); rv = ntlm_fetch_string(&auth->hdr, size, &auth->domain, auth->flags); if (rv.l > 0) { - memcpy(rv.str, domain, rv.l); + memcpy(domain, rv.str, rv.l); domain[rv.l] = '\0'; - debug("ntlm_unpack_auth: Domain '%s'.\n", domain); + debug("ntlm_unpack_auth: Domain '%s' (len=%d).\n", domain, rv.l); } if (rv.l >= size) { debug("ntlm_unpack_auth: Domain length %d too big for %d byte packet.\n", rv.l , size); @@ -281,9 +285,9 @@ rv = ntlm_fetch_string(&auth->hdr, size, &auth->user, auth->flags); if (rv.l > 0) { - memcpy(rv.str, user, rv.l); + memcpy(user, rv.str, rv.l); user[rv.l] = '\0'; - debug("ntlm_unpack_auth: Username '%s'.\n", user); + debug("ntlm_unpack_auth: Username '%s' (len=%d).\n", user, rv.l); } else return NTLM_ERR_LOGON; diff -u -r -N squid-3.2.0.16/lib/ntlmauth/ntlmauth.h squid-3.2.0.17/lib/ntlmauth/ntlmauth.h --- squid-3.2.0.16/lib/ntlmauth/ntlmauth.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/lib/ntlmauth/ntlmauth.h 2012-04-13 01:43:26.000000000 +1200 @@ -224,7 +224,7 @@ strhdr user; /**< Username */ strhdr workstation; /**< Workstation name */ strhdr sessionkey; /**< Session key for server's use */ - int32_t flags; /**< Request flags */ + uint32_t flags; /**< Request flags */ char payload[256 * 6]; /**< String data */ } ntlm_authenticate; diff -u -r -N squid-3.2.0.16/RELEASENOTES.html squid-3.2.0.17/RELEASENOTES.html --- squid-3.2.0.16/RELEASENOTES.html 2012-03-07 17:09:24.000000000 +1300 +++ squid-3.2.0.17/RELEASENOTES.html 2012-04-13 02:45:46.000000000 +1200 @@ -2,10 +2,10 @@ - Squid 3.2.0.16 release notes + Squid 3.2.0.17 release notes -

Squid 3.2.0.16 release notes

+

Squid 3.2.0.17 release notes

Squid Developers


@@ -25,17 +25,18 @@

3. Changes to squid.conf since Squid-3.1

@@ -72,7 +73,7 @@

1. Notice

-

The Squid Team are pleased to announce the release of Squid-3.2.0.16 for testing.

+

The Squid Team are pleased to announce the release of Squid-3.2.0.17 for testing.

This new release is available for download from http://www.squid-cache.org/Versions/v3/3.2/ or the mirrors.

@@ -100,6 +101,7 @@

The most important of these new features are:

  • Fixed CVE-2009-0801 : NAT interception vulnerability to malicious clients.
  • +
  • NCSA helper DES algorithm password limits
  • SMP scalability
  • Helper Multiplexer and On-Demand
  • Helper Name Changes
  • @@ -132,7 +134,27 @@ error status page.

    -

    2.2 SMP scalability +

    2.2 NCSA helper DES algorithm password limits +

    + +

    Details in Advisory +SQUID-2011:2

    + +

    The DES algorithm used by the NCSA Basic authentication helper has an +limit of 8 bytes but some implementations do not error when truncating +longer passwords down to this unsafe level.

    + +

    This both significantly lowers the threshold of difficulty decrypting +captured password files and hides from users the fact that the extra bits +of their chosen long password is not being utilized.

    + +

    The NCSA helper bundled with Squid will prevent passwords longer than 8 +characters being sent to the DES algorithm. The MD5 hash algorithm which +supports longer than 8 character passwords is also supported by this helper +and should be used instead.

    + + +

    2.3 SMP scalability

    The new "workers" squid.conf option can be used to launch multiple worker @@ -176,7 +198,7 @@ configuration" and "SMP-Related Macros" sections in squid.conf.documented.

    -

    2.3 Helper Multiplexer +

    2.4 Helper Multiplexer

    The helper multiplexer's purpose is to relieve some of the burden @@ -224,7 +246,7 @@

    -

    2.4 Helpers On-Demand +

    2.5 Helpers On-Demand

    Traditionally Squid has been configured with a fixed number of helpers and started them during @@ -260,7 +282,7 @@ of starting the maximum number of helpers will occur.

    -

    2.5 Helper Name Changes +

    2.6 Helper Name Changes

    To improve the understanding of what each helper does and where it should be used the helper binaries @@ -343,7 +365,7 @@

    -

    2.6 Multi-Lingual manuals +

    2.7 Multi-Lingual manuals

    The man(8) and man(1) pages bundled with Squid are now provided online for all @@ -356,7 +378,7 @@ This move begins the Localization of the internal administrator facing manuals.

    -

    2.7 Solaris 10 pthreads Support (Experimental) +

    2.8 Solaris 10 pthreads Support (Experimental)

    Automatic detection and use of the pthreads library available from Solaris 10

    @@ -368,7 +390,7 @@ We recommend giving AUFS a try for faster disk storage and encourage feedback.

    -

    2.8 Surrogate/1.0 protocol extensions to HTTP +

    2.9 Surrogate/1.0 protocol extensions to HTTP

    The Surrogate extensions to HTTP protocol enable an origin web server to specify separate @@ -393,7 +415,7 @@ is required to prevent an unacceptable surrogate ID of 'localhost' being generated.

    -

    2.9 Logging Infrastructure Updated +

    2.10 Logging Infrastructure Updated

    The advanced logging modules introduced in Squid-2.7 are now available from Squid-3.2.

    @@ -421,7 +443,7 @@ They also now log all client requests, if there was no Referer or User-Agent header a dash (-) is logged.

    -

    2.10 Client Bandwidth Limits +

    2.11 Client Bandwidth Limits

    In mobile environments, Squid may need to limit Squid-to-client bandwidth @@ -453,14 +475,14 @@ high-bandwidth environments.

    -

    2.11 Better eCAP Suport +

    2.12 Better eCAP Suport

    Support for libecap version 0.2.0 has been added with this series of Squid. Bringing better support for body handling, and logging.

    -

    2.12 Cache Manager access changes +

    2.13 Cache Manager access changes

    The Squid Cache Manager has previously only been accessible under the cache_object:// diff -u -r -N squid-3.2.0.16/src/cf.data.pre squid-3.2.0.17/src/cf.data.pre --- squid-3.2.0.16/src/cf.data.pre 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/cf.data.pre 2012-04-13 01:43:26.000000000 +1200 @@ -563,9 +563,8 @@ cached entry should be initiated without needing to wait for a new reply. (default is for no grace period) protocol=2.5 Compatibility mode for Squid-2.5 external acl helpers - ipv4 / ipv6 IP-mode used to communicate to this helper. - For compatability with older configurations and helpers - the default is currently 'ipv4'. + ipv4 / ipv6 IP protocol used to communicate with this helper. + The default is to auto-detect IPv6 and use it when available. FORMAT specifications @@ -1978,10 +1977,10 @@ Use this ACL to bypass server certificate validation errors. For example, the following lines will bypass all validation errors - when talking to servers located at 172.16.0.0/16. All other + when talking to servers for example.com. All other validation errors will result in ERR_SECURE_CONNECT_FAIL error. - acl BrokenServersAtTrustedIP dst 172.16.0.0/16 + acl BrokenServersAtTrustedIP dstdomain example.com sslproxy_cert_error allow BrokenServersAtTrustedIP sslproxy_cert_error deny all diff -u -r -N squid-3.2.0.16/src/comm/ConnOpener.cc squid-3.2.0.17/src/comm/ConnOpener.cc --- squid-3.2.0.16/src/comm/ConnOpener.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/ConnOpener.cc 2012-04-13 01:43:26.000000000 +1200 @@ -20,6 +20,7 @@ Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler, time_t ctimeout) : AsyncJob("Comm::ConnOpener"), host_(NULL), + temporaryFd_(-1), conn_(c), callback_(handler), totalTries_(0), @@ -63,15 +64,6 @@ calls_.timeout_ = NULL; } - // rollback what we can from the job state - if (conn_ != NULL && conn_->isOpen()) { - // drop any handlers now to save a lot of cycles later - Comm::SetSelect(conn_->fd, COMM_SELECT_WRITE, NULL, NULL, 0); - commUnsetConnTimeout(conn_); - // it never reached fully open, so abort the FD - conn_->close(); - } - if (callback_ != NULL) { if (callback_->canceled()) callback_ = NULL; @@ -80,6 +72,12 @@ doneConnecting(COMM_ERR_CONNECT, 0); } + // rollback what we can from the job state + if (temporaryFd_ >= 0) { + // doneConnecting() handles partial FD connection cleanup + doneConnecting(COMM_ERR_CONNECT, 0); + } + AsyncJob::swanSong(); } @@ -104,7 +102,7 @@ /** * Connection attempt are completed. One way or the other. * Pass the results back to the external handler. - * NP: on connection errors the connection close() must be called first. + * NP: on errors the earlyAbort call should be cancelled first with a reason. */ void Comm::ConnOpener::doneConnecting(comm_err_t status, int xerrno) @@ -132,6 +130,21 @@ callback_ = NULL; } + if (temporaryFd_ >= 0) { + // it never reached fully open, so cleanup the FD handlers + // Note that comm_close() sequence does not happen for partially open FD + Comm::SetSelect(temporaryFd_, COMM_SELECT_WRITE, NULL, NULL, 0); + calls_.earlyAbort_ = NULL; + if (calls_.timeout_ != NULL) { + calls_.timeout_->cancel("Comm::ConnOpener::doneConnecting"); + calls_.timeout_ = NULL; + } + fd_table[temporaryFd_].timeoutHandler = NULL; + fd_table[temporaryFd_].timeout = 0; + fd_close(temporaryFd_); + temporaryFd_ = -1; + } + /* ensure cleared local state, we are done. */ conn_ = NULL; } @@ -142,15 +155,15 @@ Must(conn_ != NULL); /* get a socket open ready for connecting with */ - if (!conn_->isOpen()) { + if (temporaryFd_ < 0) { #if USE_IPV6 /* outbound sockets have no need to be protocol agnostic. */ if (conn_->remote.IsIPv4()) { conn_->local.SetIPv4(); } #endif - conn_->fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, conn_->local, conn_->flags, conn_->tos, conn_->nfmark, host_); - if (!conn_->isOpen()) { + temporaryFd_ = comm_openex(SOCK_STREAM, IPPROTO_TCP, conn_->local, conn_->flags, conn_->tos, conn_->nfmark, host_); + if (temporaryFd_ < 0) { doneConnecting(COMM_ERR_CONNECT, 0); return; } @@ -158,12 +171,20 @@ typedef CommCbMemFunT abortDialer; calls_.earlyAbort_ = JobCallback(5, 4, abortDialer, this, Comm::ConnOpener::earlyAbort); - comm_add_close_handler(conn_->fd, calls_.earlyAbort_); + comm_add_close_handler(temporaryFd_, calls_.earlyAbort_); typedef CommCbMemFunT timeoutDialer; calls_.timeout_ = JobCallback(5, 4, timeoutDialer, this, Comm::ConnOpener::timeout); debugs(5, 3, HERE << conn_ << " timeout " << connectTimeout_); - commSetConnTimeout(conn_, connectTimeout_, calls_.timeout_); + + // Update the fd_table directly because conn_ is not yet storing the FD + assert(temporaryFd_ < Squid_MaxFD); + assert(fd_table[temporaryFd_].flags.open); + typedef CommTimeoutCbParams Params; + Params ¶ms = GetCommParams(calls_.timeout_); + params.conn = conn_; + fd_table[temporaryFd_].timeoutHandler = calls_.timeout_; + fd_table[temporaryFd_].timeout = squid_curtime + (time_t) connectTimeout_; connectStart_ = squid_curtime; connect(); @@ -172,6 +193,9 @@ void Comm::ConnOpener::connected() { + conn_->fd = temporaryFd_; + temporaryFd_ = -1; + /* * stats.conn_open is used to account for the number of * connections that we have open to the peer, so we can limit @@ -206,20 +230,18 @@ totalTries_++; - switch (comm_connect_addr(conn_->fd, conn_->remote) ) { + switch (comm_connect_addr(temporaryFd_, conn_->remote) ) { case COMM_INPROGRESS: // check for timeout FIRST. if (squid_curtime - connectStart_ > connectTimeout_) { debugs(5, 5, HERE << conn_ << ": * - ERR took too long already."); calls_.earlyAbort_->cancel("Comm::ConnOpener::connect timed out"); - calls_.earlyAbort_ = NULL; - conn_->close(); doneConnecting(COMM_TIMEOUT, errno); return; } else { debugs(5, 5, HERE << conn_ << ": COMM_INPROGRESS"); - Comm::SetSelect(conn_->fd, COMM_SELECT_WRITE, Comm::ConnOpener::InProgressConnectRetry, this, 0); + Comm::SetSelect(temporaryFd_, COMM_SELECT_WRITE, Comm::ConnOpener::InProgressConnectRetry, new Pointer(this), 0); } break; @@ -236,19 +258,15 @@ if (squid_curtime - connectStart_ > connectTimeout_) { debugs(5, 5, HERE << conn_ << ": * - ERR took too long to receive response."); calls_.earlyAbort_->cancel("Comm::ConnOpener::connect timed out"); - calls_.earlyAbort_ = NULL; - conn_->close(); doneConnecting(COMM_TIMEOUT, errno); } else if (failRetries_ < Config.connect_retries) { debugs(5, 5, HERE << conn_ << ": * - try again"); - eventAdd("Comm::ConnOpener::DelayedConnectRetry", Comm::ConnOpener::DelayedConnectRetry, this, 0.05, 0); + eventAdd("Comm::ConnOpener::DelayedConnectRetry", Comm::ConnOpener::DelayedConnectRetry, new Pointer(this), 0.05, 0); return; } else { // send ERROR back to the upper layer. debugs(5, 5, HERE << conn_ << ": * - ERR tried too many times already."); calls_.earlyAbort_->cancel("Comm::ConnOpener::connect failed"); - calls_.earlyAbort_ = NULL; - conn_->close(); doneConnecting(COMM_ERR_CONNECT, errno); } } @@ -301,14 +319,16 @@ void Comm::ConnOpener::InProgressConnectRetry(int fd, void *data) { - ConnOpener *cs = static_cast(data); - assert(cs); - - // Ew. we are now outside the all AsyncJob protections. - // get back inside by scheduling another call... - typedef NullaryMemFunT Dialer; - AsyncCall::Pointer call = JobCallback(5, 4, Dialer, cs, Comm::ConnOpener::connect); - ScheduleCallHere(call); + Pointer *ptr = static_cast(data); + assert(ptr); + if (ConnOpener *cs = ptr->valid()) { + // Ew. we are now outside the all AsyncJob protections. + // get back inside by scheduling another call... + typedef NullaryMemFunT Dialer; + AsyncCall::Pointer call = JobCallback(5, 4, Dialer, cs, Comm::ConnOpener::connect); + ScheduleCallHere(call); + } + delete ptr; } /* Legacy Wrapper for the retry event with small delay after errors. @@ -317,12 +337,14 @@ void Comm::ConnOpener::DelayedConnectRetry(void *data) { - ConnOpener *cs = static_cast(data); - assert(cs); - - // Ew. we are now outside the all AsyncJob protections. - // get back inside by scheduling another call... - typedef NullaryMemFunT Dialer; - AsyncCall::Pointer call = JobCallback(5, 4, Dialer, cs, Comm::ConnOpener::connect); - ScheduleCallHere(call); + Pointer *ptr = static_cast(data); + assert(ptr); + if (ConnOpener *cs = ptr->valid()) { + // Ew. we are now outside the all AsyncJob protections. + // get back inside by scheduling another call... + typedef NullaryMemFunT Dialer; + AsyncCall::Pointer call = JobCallback(5, 4, Dialer, cs, Comm::ConnOpener::connect); + ScheduleCallHere(call); + } + delete ptr; } diff -u -r -N squid-3.2.0.16/src/comm/ConnOpener.h squid-3.2.0.17/src/comm/ConnOpener.h --- squid-3.2.0.16/src/comm/ConnOpener.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/ConnOpener.h 2012-04-13 01:43:26.000000000 +1200 @@ -21,6 +21,8 @@ virtual void swanSong(); public: + typedef CbcPointer Pointer; + virtual bool doneAll() const; ConnOpener(Comm::ConnectionPointer &, AsyncCall::Pointer &handler, time_t connect_timeout); @@ -45,7 +47,8 @@ private: char *host_; ///< domain name we are trying to connect to. - Comm::ConnectionPointer conn_; ///< single connection currently being opened. + int temporaryFd_; ///< the FD being opened. Do NOT set conn_->fd until it is fully open. + Comm::ConnectionPointer conn_; ///< single connection currently to be opened. AsyncCall::Pointer callback_; ///< handler to be called on connection completion. int totalTries_; ///< total number of connection attempts over all destinations so far. diff -u -r -N squid-3.2.0.16/src/comm/Makefile.am squid-3.2.0.17/src/comm/Makefile.am --- squid-3.2.0.16/src/comm/Makefile.am 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/Makefile.am 2012-04-13 01:43:26.000000000 +1200 @@ -23,6 +23,7 @@ ModSelectWin32.cc \ TcpAcceptor.cc \ TcpAcceptor.h \ + UdpOpenDialer.h \ Write.cc \ Write.h \ \ diff -u -r -N squid-3.2.0.16/src/comm/Makefile.in squid-3.2.0.17/src/comm/Makefile.in --- squid-3.2.0.16/src/comm/Makefile.in 2012-03-07 15:46:14.000000000 +1300 +++ squid-3.2.0.17/src/comm/Makefile.in 2012-04-13 01:46:06.000000000 +1200 @@ -330,6 +330,7 @@ ModSelectWin32.cc \ TcpAcceptor.cc \ TcpAcceptor.h \ + UdpOpenDialer.h \ Write.cc \ Write.h \ \ diff -u -r -N squid-3.2.0.16/src/comm/ModKqueue.cc squid-3.2.0.17/src/comm/ModKqueue.cc --- squid-3.2.0.16/src/comm/ModKqueue.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/ModKqueue.cc 2012-04-13 01:43:26.000000000 +1200 @@ -61,6 +61,7 @@ #include "fde.h" #include "Store.h" #include "SquidTime.h" +#include "StatCounters.h" #if HAVE_SYS_EVENT_H #include diff -u -r -N squid-3.2.0.16/src/comm/ModSelect.cc squid-3.2.0.17/src/comm/ModSelect.cc --- squid-3.2.0.16/src/comm/ModSelect.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/ModSelect.cc 2012-04-13 01:43:26.000000000 +1200 @@ -37,13 +37,13 @@ #include "squid-old.h" #include "comm/Connection.h" #include "comm/Loops.h" +#include "fde.h" #include "ICP.h" #include "mgr/Registration.h" #include "SquidTime.h" #include "StatCounters.h" #include "StatHist.h" #include "Store.h" -#include "fde.h" static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */ diff -u -r -N squid-3.2.0.16/src/comm/ModSelectWin32.cc squid-3.2.0.17/src/comm/ModSelectWin32.cc --- squid-3.2.0.16/src/comm/ModSelectWin32.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/comm/ModSelectWin32.cc 2012-04-13 01:43:26.000000000 +1200 @@ -30,14 +30,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ - #include "squid.h" #if USE_SELECT_WIN32 #include "squid-old.h" +#include "comm/Connection.h" #include "comm/Loops.h" #include "fde.h" +#include "ICP.h" #include "mgr/Registration.h" #include "SquidTime.h" #include "StatCounters.h" @@ -168,10 +169,10 @@ static int fdIsIcp(int fd) { - if (fd == theInIcpConnection) + if (icpIncomingConn != NULL && fd == icpIncomingConn->fd) return 1; - if (fd == theOutIcpConnection) + if (icpOutgoingConn != NULL && fd == icpOutgoingConn->fd) return 1; return 0; @@ -249,7 +250,7 @@ for (i = 0; i < nfds; i++) { fd = fds[i]; - if (__WSAFDIsSet(fd_table[fd].win32.handle, &read_mask)) { + if (FD_ISSET(fd, &read_mask)) { if ((hdl = fd_table[fd].read_handler) != NULL) { fd_table[fd].read_handler = NULL; commUpdateReadBits(fd, NULL); @@ -259,7 +260,7 @@ } } - if (__WSAFDIsSet(fd_table[fd].win32.handle, &write_mask)) { + if (FD_ISSET(fd, &write_mask)) { if ((hdl = fd_table[fd].write_handler) != NULL) { fd_table[fd].write_handler = NULL; commUpdateWriteBits(fd, NULL); @@ -281,12 +282,11 @@ int nevents; icp_io_events = 0; - if (theInIcpConnection >= 0) - fds[nfds++] = theInIcpConnection; + if (Comm::IsConnOpen(icpIncomingConn)) + fds[nfds++] = icpIncomingConn->fd; - if (theInIcpConnection != theOutIcpConnection) - if (theOutIcpConnection >= 0) - fds[nfds++] = theOutIcpConnection; + if (Comm::IsConnOpen(icpOutgoingConn) && icpIncomingConn != icpOutgoingConn) + fds[nfds++] = icpOutgoingConn->fd; if (nfds == 0) return; @@ -412,7 +412,7 @@ if (no_bits) continue; - if (__WSAFDIsSet(fd_table[fd].win32.handle, &readfds) && fd_table[fd].flags.read_pending) { + if (FD_ISSET(fd, &readfds) && fd_table[fd].flags.read_pending) { FD_SET(fd, &pendingfds); pending++; } @@ -423,11 +423,11 @@ /* Check each open socket for a handler. */ if (fd_table[i].read_handler) { - assert(__WSAFDIsSet(fd_table[i].win32.handle, readfds)); + assert(FD_ISSET(i, readfds)); } if (fd_table[i].write_handler) { - assert(__WSAFDIsSet(fd_table[i].win32.handle, writefds)); + assert(FD_ISSET(i, writefds)); } } @@ -506,7 +506,7 @@ debugs(5, 9, "FD " << fd << " bit set for reading"); - assert(__WSAFDIsSet(fd_table[fd].win32.handle, readfds)); + assert(FD_ISSET(fd, readfds)); #endif @@ -592,7 +592,7 @@ debugs(5, 9, "FD " << fd << " bit set for writing"); - assert(__WSAFDIsSet(fd_table[fd].win32.handle, writefds)); + assert(FD_ISSET(fd, writefds)); #endif @@ -730,9 +730,9 @@ FD_ZERO(&write_x); tv.tv_sec = tv.tv_usec = 0; - if (__WSAFDIsSet(fd_table[fd].win32.handle, readfds)) + if (FD_ISSET(fd, readfds)) FD_SET(fd, &read_x); - else if (__WSAFDIsSet(fd_table[fd].win32.handle, writefds)) + else if (FD_ISSET(fd, writefds)) FD_SET(fd, &write_x); else continue; @@ -795,10 +795,10 @@ void commUpdateReadBits(int fd, PF * handler) { - if (handler && !__WSAFDIsSet(fd_table[fd].win32.handle, &global_readfds)) { + if (handler && !FD_ISSET(fd, &global_readfds)) { FD_SET(fd, &global_readfds); nreadfds++; - } else if (!handler && __WSAFDIsSet(fd_table[fd].win32.handle, &global_readfds)) { + } else if (!handler && FD_ISSET(fd, &global_readfds)) { FD_CLR(fd, &global_readfds); nreadfds--; } @@ -807,10 +807,10 @@ void commUpdateWriteBits(int fd, PF * handler) { - if (handler && !__WSAFDIsSet(fd_table[fd].win32.handle, &global_writefds)) { + if (handler && !FD_ISSET(fd, &global_writefds)) { FD_SET(fd, &global_writefds); nwritefds++; - } else if (!handler && __WSAFDIsSet(fd_table[fd].win32.handle, &global_writefds)) { + } else if (!handler && FD_ISSET(fd, &global_writefds)) { FD_CLR(fd, &global_writefds); nwritefds--; } diff -u -r -N squid-3.2.0.16/src/comm/UdpOpenDialer.h squid-3.2.0.17/src/comm/UdpOpenDialer.h --- squid-3.2.0.16/src/comm/UdpOpenDialer.h 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/comm/UdpOpenDialer.h 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,27 @@ +#ifndef SQUID_COMM_UDPOPENDIALER_H +#define SQUID_COMM_UDPOPENDIALER_H + +#include "ipc/StartListening.h" + +namespace Comm +{ + +/// dials a UDP port-opened call +class UdpOpenDialer: public CallDialer, + public Ipc::StartListeningCb +{ +public: + typedef void (*Handler)(const Comm::ConnectionPointer &conn, int errNo); + UdpOpenDialer(Handler aHandler): handler(aHandler) {} + + virtual void print(std::ostream &os) const { startPrint(os) << ')'; } + virtual bool canDial(AsyncCall &) const { return true; } + virtual void dial(AsyncCall &) { (handler)(conn, errNo); } + +public: + Handler handler; +}; + +} // namespace Comm + +#endif /* SQUID_COMM_UDPOPENDIALER_H */ diff -u -r -N squid-3.2.0.16/src/eui/Eui48.cc squid-3.2.0.17/src/eui/Eui48.cc --- squid-3.2.0.16/src/eui/Eui48.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/eui/Eui48.cc 2012-04-13 01:43:26.000000000 +1200 @@ -158,9 +158,7 @@ bool Eui::Eui48::lookup(const Ip::Address &c) { - struct arpreq arpReq; #if !_SQUID_WINDOWS_ - struct sockaddr_in *sa = NULL; #endif /* !_SQUID_WINDOWS_ */ Ip::Address ipAddr = c; @@ -192,9 +190,10 @@ /* * Set up structures for ARP lookup with blank interface name */ + struct arpreq arpReq; memset(&arpReq, '\0', sizeof(arpReq)); - sa = (sockaddr_in*)&arpReq.arp_pa; + struct sockaddr_in *sa = (struct sockaddr_in*)&arpReq.arp_pa; ipAddr.GetSockAddr(*sa); /* Query ARP table */ @@ -316,10 +315,10 @@ int tmpSocket = socket(AF_INET,SOCK_STREAM,0); /* Set up structures for ARP lookup with blank interface name */ - + struct arpreq arpReq; memset(&arpReq, '\0', sizeof(arpReq)); - sa = (sockaddr_in*)&arpReq.arp_pa; + struct sockaddr_in *sa = (struct sockaddr_in*)&arpReq.arp_pa; ipAddr.GetSockAddr(*sa); /* Query ARP table */ @@ -368,10 +367,10 @@ /* * Set up structures for ARP lookup with blank interface name */ - + struct arpreq arpReq; memset(&arpReq, '\0', sizeof(arpReq)); - sa = (struct sockaddr_in*) &arpReq.arp_pa; + struct sockaddr_in *sa = (struct sockaddr_in*)&arpReq.arp_pa; ipAddr.GetSockAddr(*sa); /* Query ARP table */ @@ -460,6 +459,7 @@ DWORD i; + struct arpreq arpReq; memset(&arpReq, '\0', sizeof(arpReq)); /* Get size of Windows ARP table */ diff -u -r -N squid-3.2.0.16/src/fs/ufs/store_dir_ufs.cc squid-3.2.0.17/src/fs/ufs/store_dir_ufs.cc --- squid-3.2.0.16/src/fs/ufs/store_dir_ufs.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/fs/ufs/store_dir_ufs.cc 2012-04-13 01:43:26.000000000 +1200 @@ -804,9 +804,8 @@ buf.init(header.record_size, header.record_size); buf.append(reinterpret_cast(&header), sizeof(header)); // Pad to keep in sync with UFSSwapDir::writeCleanStart(). - // TODO: When MemBuf::spaceSize() is fixed not to subtract one, - // memset() space() with zeroes and use spaceSize() below. - buf.appended(static_cast(header.record_size) - sizeof(header)); + memset(buf.space(), 0, header.gapSize()); + buf.appended(header.gapSize()); file_write(swaplog_fd, -1, buf.content(), buf.contentSize(), NULL, NULL, buf.freeFunc()); } @@ -895,6 +894,7 @@ /*copy the header */ memcpy(state->outbuf, &header, sizeof(StoreSwapLogHeader)); // Leave a gap to keep in sync with UFSSwapDir::openTmpSwapLog(). + memset(state->outbuf + sizeof(StoreSwapLogHeader), 0, header.gapSize()); state->outbuf_offset += header.record_size; state->walker = repl->WalkInit(repl); @@ -944,6 +944,7 @@ s.refcount = e.refcount; s.flags = e.flags; memcpy(&s.key, e.key, SQUID_MD5_DIGEST_LENGTH); + s.finalize(); memcpy(outbuf + outbuf_offset, &s, ss); outbuf_offset += ss; /* buffered write */ @@ -1052,6 +1053,7 @@ s->refcount = e.refcount; s->flags = e.flags; memcpy(s->key, e.key, SQUID_MD5_DIGEST_LENGTH); + s->finalize(); file_write(swaplog_fd, -1, s, diff -u -r -N squid-3.2.0.16/src/fs/ufs/ufscommon.cc squid-3.2.0.17/src/fs/ufs/ufscommon.cc --- squid-3.2.0.16/src/fs/ufs/ufscommon.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/fs/ufs/ufscommon.cc 2012-04-13 01:43:26.000000000 +1200 @@ -95,6 +95,7 @@ } }; +#if UNUSED_CODE /// Parse a swap header entry created on a system with 32-bit size_t, time_t and sfileno /// this is typical of 32-bit systems without large file support and with old kernels /// NP: SQUID_MD5_DIGEST_LENGTH is very risky still. @@ -213,6 +214,20 @@ } return true; } +#endif /* UNUSED_CODE */ + +/// swap.state v2 log parser +class UFSSwapLogParser_v2: public UFSSwapLogParser +{ +public: + UFSSwapLogParser_v2(FILE *fp): UFSSwapLogParser(fp) { + record_size = sizeof(StoreSwapLogData); + } + bool ReadRecord(StoreSwapLogData &swapData) { + assert(log); + return fread(&swapData, sizeof(StoreSwapLogData), 1, log) == 1; + } +}; UFSSwapLogParser *UFSSwapLogParser::GetUFSSwapLogParser(FILE *fp) @@ -230,10 +245,18 @@ return new UFSSwapLogParser_v1_32bs(fp); // Um. 32-bits except time_t, and can't determine that. } + debugs(47, 2, "Swap file version: " << header.version); + if (header.version == 1) { if (fseek(fp, header.record_size, SEEK_SET) != 0) return NULL; + debugs(47, DBG_IMPORTANT, "Rejecting swap file v1 to avoid cache " << + "index corruption. Forcing a full cache index rebuild. " << + "See Squid bug #3441."); + return NULL; + +#if UNUSED_CODE // baseline // 32-bit sfileno // native time_t (hopefully 64-bit) @@ -272,11 +295,26 @@ debugs(47, 1, "WARNING: The swap file has wrong format!... "); debugs(47, 1, "NOTE: Cannot safely downgrade caches to short (32-bit) timestamps."); return NULL; +#endif + } + + if (header.version >= 2) { + if (!header.sane()) { + debugs(47, DBG_IMPORTANT, "ERROR: Corrupted v" << header.version << + " swap file header."); + return NULL; + } + + if (fseek(fp, header.record_size, SEEK_SET) != 0) + return NULL; + + if (header.version == 2) + return new UFSSwapLogParser_v2(fp); } - // XXX: version 2 of swapfile. This time use fixed-bit sizes for everything!! - // and preferrably write to disk in network-order bytes for the larger fields. + // TODO: v3: write to disk in network-order bytes for the larger fields? + debugs(47, DBG_IMPORTANT, "Unknown swap file version: " << header.version); return NULL; } @@ -327,7 +365,8 @@ if (!clean) flags.need_to_validate = 1; - debugs(47, 1, "Rebuilding storage in " << sd->path << " (" << (clean ? "CLEAN" : "DIRTY") << ")"); + debugs(47, DBG_IMPORTANT, "Rebuilding storage in " << sd->path << " (" << + (clean ? "clean log" : (LogParser ? "dirty log" : "no log")) << ")"); } RebuildState::~RebuildState() @@ -407,7 +446,8 @@ fd = getNextFile(&filn, &size); if (fd == -2) { - debugs(47, 1, "Done scanning " << sd->path << " swaplog (" << n_read << " entries)"); + debugs(47, DBG_IMPORTANT, "Done scanning " << sd->path << " dir (" << + n_read << " entries)"); _done = true; return; } else if (fd < 0) { @@ -417,6 +457,8 @@ assert(fd > -1); /* lets get file stats here */ + n_read++; + if (fstat(fd, &sb) < 0) { debugs(47, 1, "commonUfsDirRebuildFromDirectory: fstat(FD " << fd << "): " << xstrerror()); file_close(fd); diff -u -r -N squid-3.2.0.16/src/htcp.cc squid-3.2.0.17/src/htcp.cc --- squid-3.2.0.16/src/htcp.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/htcp.cc 2012-04-13 01:43:26.000000000 +1200 @@ -39,11 +39,11 @@ #include "acl/Acl.h" #include "comm.h" #include "comm/Loops.h" +#include "comm/UdpOpenDialer.h" #include "htcp.h" #include "http.h" #include "HttpRequest.h" #include "icmp/net_db.h" -#include "ipc/StartListening.h" #include "ip/tools.h" #include "MemBuf.h" #include "SquidTime.h" @@ -52,22 +52,6 @@ #include "StoreClient.h" #include "compat/xalloc.h" -/// dials htcpIncomingConnectionOpened call -class HtcpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb -{ -public: - typedef void (*Handler)(int errNo); - HtcpListeningStartedDialer(Handler aHandler): handler(aHandler) {} - - virtual void print(std::ostream &os) const { startPrint(os) << ')'; } - virtual bool canDial(AsyncCall &) const { return true; } - virtual void dial(AsyncCall &) { (handler)(errNo); } - -public: - Handler handler; -}; - typedef struct _Countstr Countstr; typedef struct _htcpHeader htcpHeader; @@ -246,7 +230,7 @@ RR_RESPONSE }; -static void htcpIncomingConnectionOpened(int errNo); +static void htcpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo); static uint32_t msg_id_counter = 0; static Comm::ConnectionPointer htcpOutgoingConn = NULL; @@ -1507,7 +1491,7 @@ AsyncCall::Pointer call = asyncCall(31, 2, "htcpIncomingConnectionOpened", - HtcpListeningStartedDialer(&htcpIncomingConnectionOpened)); + Comm::UdpOpenDialer(&htcpIncomingConnectionOpened)); Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, @@ -1546,17 +1530,17 @@ } static void -htcpIncomingConnectionOpened(int) +htcpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int) { - if (!Comm::IsConnOpen(htcpIncomingConn)) + if (!Comm::IsConnOpen(conn)) fatal("Cannot open HTCP Socket"); - Comm::SetSelect(htcpIncomingConn->fd, COMM_SELECT_READ, htcpRecv, NULL, 0); + Comm::SetSelect(conn->fd, COMM_SELECT_READ, htcpRecv, NULL, 0); - debugs(31, DBG_CRITICAL, "Accepting HTCP messages on " << htcpIncomingConn->local); + debugs(31, DBG_CRITICAL, "Accepting HTCP messages on " << conn->local); if (Config.Addrs.udp_outgoing.IsNoAddr()) { - htcpOutgoingConn = htcpIncomingConn; + htcpOutgoingConn = conn; debugs(31, DBG_IMPORTANT, "Sending HTCP messages from " << htcpOutgoingConn->local); } } diff -u -r -N squid-3.2.0.16/src/icp_v2.cc squid-3.2.0.17/src/icp_v2.cc --- squid-3.2.0.16/src/icp_v2.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/icp_v2.cc 2012-04-13 01:43:26.000000000 +1200 @@ -38,9 +38,10 @@ #include "squid-old.h" #include "Store.h" #include "comm.h" +#include "comm/Connection.h" #include "comm/Loops.h" +#include "comm/UdpOpenDialer.h" #include "ICP.h" -#include "comm/Connection.h" #include "HttpRequest.h" #include "acl/FilledChecklist.h" #include "acl/Acl.h" @@ -52,28 +53,10 @@ #include "icmp/net_db.h" #include "ip/Address.h" #include "ip/tools.h" -#include "ipc/StartListening.h" #include "ipcache.h" #include "rfc1738.h" -/// dials icpIncomingConnectionOpened call -class IcpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb -{ -public: - typedef void (*Handler)(int errNo); - IcpListeningStartedDialer(Handler aHandler): - handler(aHandler) {} - - virtual void print(std::ostream &os) const { startPrint(os) << ')'; } - virtual bool canDial(AsyncCall &) const { return true; } - virtual void dial(AsyncCall &) { (handler)(errNo); } - -public: - Handler handler; -}; - -static void icpIncomingConnectionOpened(int errNo); +static void icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo); /// \ingroup ServerProtocolICPInternal2 static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int); @@ -696,7 +679,7 @@ AsyncCall::Pointer call = asyncCall(12, 2, "icpIncomingConnectionOpened", - IcpListeningStartedDialer(&icpIncomingConnectionOpened)); + Comm::UdpOpenDialer(&icpIncomingConnectionOpened)); Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, @@ -732,22 +715,22 @@ } static void -icpIncomingConnectionOpened(int errNo) +icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo) { - if (!Comm::IsConnOpen(icpIncomingConn)) + if (!Comm::IsConnOpen(conn)) fatal("Cannot open ICP Port"); - Comm::SetSelect(icpIncomingConn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0); + Comm::SetSelect(conn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0); for (const wordlist *s = Config.mcast_group_list; s; s = s->next) - ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); // XXX: pass the icpIncomingConn for mcastJoinGroups usage. + ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); // XXX: pass the conn for mcastJoinGroups usage. - debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << icpIncomingConn->local); + debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << conn->local); - fd_note(icpIncomingConn->fd, "Incoming ICP port"); + fd_note(conn->fd, "Incoming ICP port"); if (Config.Addrs.udp_outgoing.IsNoAddr()) { - icpOutgoingConn = icpIncomingConn; + icpOutgoingConn = conn; debugs(12, DBG_IMPORTANT, "Sending ICP messages from " << icpOutgoingConn->local); } } diff -u -r -N squid-3.2.0.16/src/Makefile.am squid-3.2.0.17/src/Makefile.am --- squid-3.2.0.16/src/Makefile.am 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/Makefile.am 2012-04-13 01:43:26.000000000 +1200 @@ -764,6 +764,8 @@ $(COMPAT_LIB) \ $(XTRA_LIBS) +include $(srcdir)/tests/Stub.list + EXTRA_DIST = \ cf_gen_defines \ cf.data.pre \ @@ -774,7 +776,7 @@ mk-string-arrays.pl \ mk-string-arrays.awk \ repl_modules.sh \ - tests/STUB.h \ + $(STUB_SOURCE) \ mib.txt \ mime.conf.default diff -u -r -N squid-3.2.0.16/src/Makefile.in squid-3.2.0.17/src/Makefile.in --- squid-3.2.0.16/src/Makefile.in 2012-03-07 15:46:03.000000000 +1300 +++ squid-3.2.0.17/src/Makefile.in 2012-04-13 01:45:58.000000000 +1200 @@ -45,7 +45,8 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/doc/manuals/Substitute.am \ + $(srcdir)/Makefile.in $(srcdir)/tests/Stub.list \ + $(top_srcdir)/doc/manuals/Substitute.am \ $(top_srcdir)/src/Common.am check_PROGRAMS = $(am__EXEEXT_1) tests/testBoilerplate$(EXEEXT) \ tests/testCacheManager$(EXEEXT) tests/testDiskIO$(EXEEXT) \ @@ -2475,10 +2476,57 @@ $(COMPAT_LIB) \ $(XTRA_LIBS) +STUB_SOURCE = tests/STUB.h \ + tests/stub_CommIO.cc \ + tests/stub_DelayId.cc \ + tests/stub_DiskIOModule.cc \ + tests/stub_HelperChildConfig.cc \ + tests/stub_HttpReply.cc \ + tests/stub_HttpRequest.cc \ + tests/stub_MemObject.cc \ + tests/stub_MemStore.cc \ + tests/stub_Port.cc \ + tests/stub_StatHist.cc \ + tests/stub_UdsOp.cc \ + tests/stub_access_log.cc \ + tests/stub_acl.cc \ + tests/stub_cache_cf.cc \ + tests/stub_cache_manager.cc \ + tests/stub_client_db.cc \ + tests/stub_client_side_request.cc \ + tests/stub_comm.cc \ + tests/stub_debug.cc \ + tests/stub_errorpage.cc \ + tests/stub_event.cc \ + tests/stub_fd.cc \ + tests/stub_helper.cc \ + tests/stub_http.cc \ + tests/stub_icp.cc \ + tests/stub_internal.cc \ + tests/stub_ipc.cc \ + tests/stub_ipc_Forwarder.cc \ + tests/stub_ipc_TypedMsgHdr.cc \ + tests/stub_ipcache.cc \ + tests/stub_libcomm.cc \ + tests/stub_libicmp.cc \ + tests/stub_main_cc.cc \ + tests/stub_mem.cc \ + tests/stub_mem_node.cc \ + tests/stub_mime.cc \ + tests/stub_pconn.cc \ + tests/stub_stat.cc \ + tests/stub_stmem.cc \ + tests/stub_store.cc \ + tests/stub_store_client.cc \ + tests/stub_store_rebuild.cc \ + tests/stub_store_stats.cc \ + tests/stub_store_swapout.cc \ + tests/stub_tools.cc + EXTRA_DIST = cf_gen_defines cf.data.pre cf.data.depend \ DiskIO/modules.sh mk-globals-c.pl mk-globals-c.awk \ mk-string-arrays.pl mk-string-arrays.awk repl_modules.sh \ - tests/STUB.h mib.txt mime.conf.default squid.8.in + $(STUB_SOURCE) mib.txt mime.conf.default squid.8.in libAIO_a_SOURCES = \ $(AIO_WIN32_SOURCES) \ DiskIO/AIO/async_io.h \ @@ -4956,7 +5004,7 @@ .SUFFIXES: .SUFFIXES: .cc .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/src/Common.am $(top_srcdir)/doc/manuals/Substitute.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/src/Common.am $(srcdir)/tests/Stub.list $(top_srcdir)/doc/manuals/Substitute.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ diff -u -r -N squid-3.2.0.16/src/snmp_core.cc squid-3.2.0.17/src/snmp_core.cc --- squid-3.2.0.16/src/snmp_core.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/snmp_core.cc 2012-04-13 01:43:26.000000000 +1200 @@ -35,34 +35,14 @@ #include "comm.h" #include "comm/Connection.h" #include "comm/Loops.h" -#include "ipc/StartListening.h" +#include "comm/UdpOpenDialer.h" #include "ip/Address.h" #include "ip/tools.h" #include "snmp_core.h" #include "snmp/Forwarder.h" - -/// dials snmpConnectionOpened call -class SnmpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb -{ -public: - typedef void (*Handler)(const Comm::ConnectionPointer &conn, int errNo); - SnmpListeningStartedDialer(Handler aHandler): handler(aHandler) {} - - virtual void print(std::ostream &os) const { startPrint(os) << ')'; } - - virtual bool canDial(AsyncCall &) const { return true; } - virtual void dial(AsyncCall &) { (handler)(conn, errNo); } - -public: - Handler handler; -}; - - static void snmpPortOpened(const Comm::ConnectionPointer &conn, int errNo); - mib_tree_entry *mib_tree_head; mib_tree_entry *mib_tree_last; @@ -308,7 +288,7 @@ } AsyncCall::Pointer call = asyncCall(49, 2, "snmpIncomingConnectionOpened", - SnmpListeningStartedDialer(&snmpPortOpened)); + Comm::UdpOpenDialer(&snmpPortOpened)); Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, snmpIncomingConn, Ipc::fdnInSnmpSocket, call); if (!Config.Addrs.snmp_outgoing.IsNoAddr()) { @@ -325,7 +305,7 @@ snmpOutgoingConn->local.SetIPv4(); } AsyncCall::Pointer call = asyncCall(49, 2, "snmpOutgoingConnectionOpened", - SnmpListeningStartedDialer(&snmpPortOpened)); + Comm::UdpOpenDialer(&snmpPortOpened)); Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, snmpOutgoingConn, Ipc::fdnOutSnmpSocket, call); } else { snmpOutgoingConn = snmpIncomingConn; diff -u -r -N squid-3.2.0.16/src/ssl/certificate_db.h squid-3.2.0.17/src/ssl/certificate_db.h --- squid-3.2.0.16/src/ssl/certificate_db.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/ssl/certificate_db.h 2012-04-13 01:43:26.000000000 +1200 @@ -6,7 +6,6 @@ #define SQUID_SSL_CERTIFICATE_DB_H #include "ssl/gadgets.h" -#include "ssl/support.h" #if HAVE_STRING #include #endif diff -u -r -N squid-3.2.0.16/src/ssl/Makefile.am squid-3.2.0.17/src/ssl/Makefile.am --- squid-3.2.0.16/src/ssl/Makefile.am 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/ssl/Makefile.am 2012-04-13 01:43:26.000000000 +1200 @@ -21,6 +21,7 @@ SSL_CRTD_SOURCE = endif +## SSL stuff used by main Squid but not by ssl_crtd libsslsquid_la_SOURCES = \ context_storage.cc \ context_storage.h \ @@ -31,14 +32,16 @@ ErrorDetailManager.cc \ ErrorDetailManager.h \ support.cc \ - support.h + support.h \ + \ + $(SSL_CRTD_SOURCE) +## SSL stuff used by main Squid and ssl_crtd libsslutil_la_SOURCES = \ gadgets.cc \ gadgets.h \ crtd_message.cc \ - crtd_message.h \ - $(SSL_CRTD_SOURCE) + crtd_message.h libexec_PROGRAMS = \ $(SSL_CRTD) diff -u -r -N squid-3.2.0.16/src/ssl/Makefile.in squid-3.2.0.17/src/ssl/Makefile.in --- squid-3.2.0.16/src/ssl/Makefile.in 2012-03-07 15:46:26.000000000 +1300 +++ squid-3.2.0.17/src/ssl/Makefile.in 2012-04-13 01:46:17.000000000 +1200 @@ -59,14 +59,17 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libsslsquid_la_LIBADD = +am__libsslsquid_la_SOURCES_DIST = context_storage.cc context_storage.h \ + Config.cc Config.h ErrorDetail.cc ErrorDetail.h \ + ErrorDetailManager.cc ErrorDetailManager.h support.cc \ + support.h helper.cc helper.h +@USE_SSL_CRTD_TRUE@am__objects_1 = helper.lo am_libsslsquid_la_OBJECTS = context_storage.lo Config.lo \ - ErrorDetail.lo ErrorDetailManager.lo support.lo + ErrorDetail.lo ErrorDetailManager.lo support.lo \ + $(am__objects_1) libsslsquid_la_OBJECTS = $(am_libsslsquid_la_OBJECTS) libsslutil_la_LIBADD = -am__libsslutil_la_SOURCES_DIST = gadgets.cc gadgets.h crtd_message.cc \ - crtd_message.h helper.cc helper.h -@USE_SSL_CRTD_TRUE@am__objects_1 = helper.lo -am_libsslutil_la_OBJECTS = gadgets.lo crtd_message.lo $(am__objects_1) +am_libsslutil_la_OBJECTS = gadgets.lo crtd_message.lo libsslutil_la_OBJECTS = $(am_libsslutil_la_OBJECTS) @USE_SSL_CRTD_TRUE@am__EXEEXT_1 = ssl_crtd$(EXEEXT) am__installdirs = "$(DESTDIR)$(libexecdir)" @@ -105,8 +108,8 @@ $(LDFLAGS) -o $@ SOURCES = $(libsslsquid_la_SOURCES) $(libsslutil_la_SOURCES) \ $(ssl_crtd_SOURCES) -DIST_SOURCES = $(libsslsquid_la_SOURCES) \ - $(am__libsslutil_la_SOURCES_DIST) $(am__ssl_crtd_SOURCES_DIST) +DIST_SOURCES = $(am__libsslsquid_la_SOURCES_DIST) \ + $(libsslutil_la_SOURCES) $(am__ssl_crtd_SOURCES_DIST) ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -355,14 +358,15 @@ ErrorDetailManager.cc \ ErrorDetailManager.h \ support.cc \ - support.h + support.h \ + \ + $(SSL_CRTD_SOURCE) libsslutil_la_SOURCES = \ gadgets.cc \ gadgets.h \ crtd_message.cc \ - crtd_message.h \ - $(SSL_CRTD_SOURCE) + crtd_message.h @USE_SSL_CRTD_TRUE@ssl_crtd_SOURCES = ssl_crtd.cc certificate_db.cc certificate_db.h @USE_SSL_CRTD_TRUE@ssl_crtd_LDADD = $(SSLLIB) -lsslutil $(COMPAT_LIB) diff -u -r -N squid-3.2.0.16/src/StoreSwapLogData.cc squid-3.2.0.17/src/StoreSwapLogData.cc --- squid-3.2.0.16/src/StoreSwapLogData.cc 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/StoreSwapLogData.cc 2012-04-13 01:43:26.000000000 +1200 @@ -36,16 +36,53 @@ #include "StoreSwapLogData.h" #include "swap_log_op.h" -StoreSwapLogData::StoreSwapLogData(): op(0), swap_filen (0), timestamp (0), lastref (0), expires (0), lastmod(0), swap_file_sz (0), refcount (0), flags (0) +// Based on Internet Checksum (RFC 1071) algorithm but takes three 32bit ints. +// TODO: Consider Fletcher's checksum algorithm as a higher quality alternative +void +SwapChecksum24::set(uint32_t f1, uint32_t f2, uint32_t f3) { - memset (key, '\0', sizeof(key)); + uint64_t sum = f1; + sum += f2; + sum += f3; + + while (const uint64_t higherBits = sum >> 24) + sum = (sum & 0xFFFFFF) + higherBits; + + sum = ~sum; + + raw[0] = static_cast(sum); + raw[1] = static_cast(sum >> 8); + raw[2] = static_cast(sum >> 16); +} + +/// Same as 3-argument SwapChecksum24::set() but for int32_t and uint64_t +void +SwapChecksum24::set(int32_t f1, uint64_t f2) +{ + // split the second 64bit word into two 32bit words + set(static_cast(f1), + static_cast(f2 >> 32), + static_cast(f2 & 0xFFFFFFFF)); +} + +std::ostream & +SwapChecksum24::print(std::ostream &os) const +{ + return os << raw[0] << '-' << raw[1] << '-' << raw[2]; +} + +StoreSwapLogData::StoreSwapLogData() +{ + memset(this, 0, sizeof(*this)); } bool StoreSwapLogData::sane() const { - // TODO: These checks are rather weak. A corrupted swap.state may still - // cause havoc (e.g., cur_size may become astronomical). Add checksums? + SwapChecksum24 actualSum; + actualSum.set(swap_filen, swap_file_sz); + if (checksum != actualSum) + return false; const time_t minTime = -2; // -1 is common; expires sometimes uses -2 @@ -59,7 +96,33 @@ swap_file_sz > 0; // because swap headers ought to consume space } -StoreSwapLogHeader::StoreSwapLogHeader():op(SWAP_LOG_VERSION), version(1) +void +StoreSwapLogData::finalize() +{ + checksum.set(swap_filen, swap_file_sz); +} + +StoreSwapLogHeader::StoreSwapLogHeader(): op(SWAP_LOG_VERSION), version(2), + record_size(sizeof(StoreSwapLogData)) +{ + checksum.set(version, record_size, 0); +} + +bool +StoreSwapLogHeader::sane() const +{ + SwapChecksum24 actualSum; + actualSum.set(version, record_size, 0); + if (checksum != actualSum) + return false; + + return op == SWAP_LOG_VERSION && version >= 2 && record_size > 0; +} + +size_t +StoreSwapLogHeader::gapSize() const { - record_size = sizeof(StoreSwapLogData); + assert(record_size > 0); + assert(static_cast(record_size) > sizeof(*this)); + return static_cast(record_size) - sizeof(*this); } diff -u -r -N squid-3.2.0.16/src/StoreSwapLogData.h squid-3.2.0.17/src/StoreSwapLogData.h --- squid-3.2.0.16/src/StoreSwapLogData.h 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/src/StoreSwapLogData.h 2012-04-13 01:43:26.000000000 +1200 @@ -61,20 +61,45 @@ #include "squid-old.h" -/* - * Do we need to have the dirn in here? I don't think so, since we already - * know the dirn .. - */ +/// maintains a 24-bit checksum over integer fields +class SwapChecksum24 +{ +public: + SwapChecksum24() { raw[0] = raw[1] = raw[2] = 0; } + + bool operator ==(const SwapChecksum24 &o) const { + return raw[0] == o.raw[0] && raw[1] == o.raw[1] && raw[2] == o.raw[2]; + } + + bool operator !=(const SwapChecksum24 &o) const { + return !(*this == o); + } + + /// compute and store checksum based on three 32bit integers + void set(uint32_t f1, uint32_t f2, uint32_t f3); + + /// compute and store checksum based on int32_t and uint64_t integers + void set(int32_t f1, uint64_t f2); + + // printing for debugging + std::ostream &print(std::ostream &os) const; + +private: + uint8_t raw[3]; // designed to follow "op" members, in pading space +}; + +inline std::ostream & +operator <<(std::ostream &os, const SwapChecksum24 &sum) +{ + return sum.print(os); +} + /** \ingroup FielFormatSwapStateAPI - \note This information is current as of version 2.2.STABLE4 - * - \li Binary format on disk. - \li DO NOT randomly alter. - \li DO NOT add ANY virtual's. * \par - * Defines the structure of a binary swap.state file entry. + * Defines the structure of a binary swap.state file entry for UFS stores. + * TODO: Move to fs/ufs (and remove from COSS). * \note StoreSwapLogData entries are written in native machine byte order * They are not necessarily portable across architectures. @@ -84,16 +109,28 @@ public: MEMPROXY_CLASS(StoreSwapLogData); + + /// type to use for storing time-related members; must be signed + typedef int64_t SwappedTime; + StoreSwapLogData(); /// consistency self-check: whether the data appears to make sense bool sane() const; + /// call this before storing the log entry + void finalize(); + /** * Either SWAP_LOG_ADD when an object is added to the disk storage, * or SWAP_LOG_DEL when an object is deleted. */ - char op; + uint8_t op; + + /** + * Fingerprint to weed out bogus/corrupted swap.state entries. + */ + SwapChecksum24 checksum; // follows "op" because compiler will pad anyway /** * The 32-bit file number which maps to a pathname. @@ -105,20 +142,20 @@ sfileno swap_filen; /** - * A 32-bit Unix time value that represents the time when + * A Unix time value that represents the time when * the origin server generated this response. If the response * has a valid Date: header, this timestamp corresponds * to that time. Otherwise, it is set to the Squid process time * when the response is read (as soon as the end of headers are found). */ - time_t timestamp; + SwappedTime timestamp; /** * The last time that a client requested this object. * Strictly speaking, this time is set whenever the StoreEntry * is locked (via storeLockObject()). */ - time_t lastref; + SwappedTime lastref; /** * The value of the response's Expires: header, if any. @@ -129,14 +166,14 @@ * where Squid sets expires to -2. This happens for the * internal "netdb" object and for FTP URL responses. */ - time_t expires; + SwappedTime expires; /** * The value of the response's Last-modified: header, if any. * This is set to -1 if there is no Last-modified: header, * or if it is unparseable. */ - time_t lastmod; + SwappedTime lastmod; /** * This is the number of bytes that the object occupies on @@ -167,13 +204,23 @@ MEMPROXY_CLASS_INLINE(StoreSwapLogData); /// \ingroup FileFormatSwapStateAPI +/// Swap log starts with this binary structure. class StoreSwapLogHeader { public: + // sets default values for this Squid version; loaded values may differ StoreSwapLogHeader(); - char op; - int version; - int record_size; + + /// consistency self-check: whether the data appears to make sense + bool sane() const; + + /// number of bytes after the log header before the first log entry + size_t gapSize() const; + + uint8_t op; + SwapChecksum24 checksum; // follows "op" because compiler will pad anyway + int32_t version; + int32_t record_size; }; diff -u -r -N squid-3.2.0.16/src/tests/stub_CommIO.cc squid-3.2.0.17/src/tests/stub_CommIO.cc --- squid-3.2.0.16/src/tests/stub_CommIO.cc 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/tests/stub_CommIO.cc 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,37 @@ +#include "squid.h" +#include "DiskIO/DiskThreads/CommIO.h" + +bool CommIO::Initialised = false; +bool CommIO::DoneSignalled = false; +int CommIO::DoneFD = -1; +int CommIO::DoneReadFD = -1; + +void +CommIO::ResetNotifications() +{ + fatal("Not Implemented"); +} + +void +CommIO::Initialise() +{ + fatal("Not Implemented"); +} + +void +CommIO::NotifyIOClose() +{ + fatal("Not Implemented"); +} + +void +CommIO::NULLFDHandler(int, void *) +{ + fatal("Not Implemented"); +} + +void +CommIO::FlushPipe() +{ + fatal("Not Implemented"); +} diff -u -r -N squid-3.2.0.16/src/tests/stub_ipc_TypedMsgHdr.cc squid-3.2.0.17/src/tests/stub_ipc_TypedMsgHdr.cc --- squid-3.2.0.16/src/tests/stub_ipc_TypedMsgHdr.cc 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/tests/stub_ipc_TypedMsgHdr.cc 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,14 @@ +#include "squid.h" + +#define STUB_API "TypedMsgHdr.cc" +#include "tests/STUB.h" + +#include "ipc/TypedMsgHdr.h" + +Ipc::TypedMsgHdr::TypedMsgHdr() STUB +void Ipc::TypedMsgHdr::checkType(int) const STUB +void Ipc::TypedMsgHdr::setType(int) STUB +void Ipc::TypedMsgHdr::getFixed(void*, size_t) const STUB +void Ipc::TypedMsgHdr::putFixed(void const*, size_t) STUB +void Ipc::TypedMsgHdr::getString(String&) const STUB +void Ipc::TypedMsgHdr::putString(String const&) STUB diff -u -r -N squid-3.2.0.16/src/tests/Stub.list squid-3.2.0.17/src/tests/Stub.list --- squid-3.2.0.16/src/tests/Stub.list 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/tests/Stub.list 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,46 @@ +STUB_SOURCE= tests/STUB.h \ + tests/stub_CommIO.cc \ + tests/stub_DelayId.cc \ + tests/stub_DiskIOModule.cc \ + tests/stub_HelperChildConfig.cc \ + tests/stub_HttpReply.cc \ + tests/stub_HttpRequest.cc \ + tests/stub_MemObject.cc \ + tests/stub_MemStore.cc \ + tests/stub_Port.cc \ + tests/stub_StatHist.cc \ + tests/stub_UdsOp.cc \ + tests/stub_access_log.cc \ + tests/stub_acl.cc \ + tests/stub_cache_cf.cc \ + tests/stub_cache_manager.cc \ + tests/stub_client_db.cc \ + tests/stub_client_side_request.cc \ + tests/stub_comm.cc \ + tests/stub_debug.cc \ + tests/stub_errorpage.cc \ + tests/stub_event.cc \ + tests/stub_fd.cc \ + tests/stub_helper.cc \ + tests/stub_http.cc \ + tests/stub_icp.cc \ + tests/stub_internal.cc \ + tests/stub_ipc.cc \ + tests/stub_ipc_Forwarder.cc \ + tests/stub_ipc_TypedMsgHdr.cc \ + tests/stub_ipcache.cc \ + tests/stub_libcomm.cc \ + tests/stub_libicmp.cc \ + tests/stub_main_cc.cc \ + tests/stub_mem.cc \ + tests/stub_mem_node.cc \ + tests/stub_mime.cc \ + tests/stub_pconn.cc \ + tests/stub_stat.cc \ + tests/stub_stmem.cc \ + tests/stub_store.cc \ + tests/stub_store_client.cc \ + tests/stub_store_rebuild.cc \ + tests/stub_store_stats.cc \ + tests/stub_store_swapout.cc \ + tests/stub_tools.cc diff -u -r -N squid-3.2.0.16/src/tests/stub_mem_node.cc squid-3.2.0.17/src/tests/stub_mem_node.cc --- squid-3.2.0.16/src/tests/stub_mem_node.cc 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/tests/stub_mem_node.cc 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,48 @@ +/* + * $Id$ + * + * DEBUG: section 84 Helper process maintenance + * AUTHOR: Robert Collins + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" +#include "mem_node.h" + +mem_node::mem_node(int64_t offset):nodeBuffer(0,offset,data) +{ + fatal ("Not implemented"); +} + +size_t +mem_node::InUseCount() +{ + fatal ("Not implemented"); + return 0; +} diff -u -r -N squid-3.2.0.16/src/tests/stub_stat.cc squid-3.2.0.17/src/tests/stub_stat.cc --- squid-3.2.0.16/src/tests/stub_stat.cc 1970-01-01 12:00:00.000000000 +1200 +++ squid-3.2.0.17/src/tests/stub_stat.cc 2012-04-13 01:43:26.000000000 +1200 @@ -0,0 +1,40 @@ +/* + * $Id$ + * + * DEBUG: section 18 Cache Manager Statistics + * AUTHOR: Robert Collins + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid-old.h" + +/* + * DO NOT MODIFY: + * arch-tag: 910d285d-c514-4592-adac-1f079ca734ab + */ diff -u -r -N squid-3.2.0.16/tools/cachemgr.cgi.8 squid-3.2.0.17/tools/cachemgr.cgi.8 --- squid-3.2.0.16/tools/cachemgr.cgi.8 2012-03-07 17:09:22.000000000 +1300 +++ squid-3.2.0.17/tools/cachemgr.cgi.8 2012-04-13 02:45:45.000000000 +1200 @@ -49,7 +49,7 @@ program. . .SH AUTHOR -Derived from Harvest. Further developed by by numerous individuals from +Derived from Harvest. Further developed by numerous individuals from the internet community. Development is led by Duane Wessels of the National Laboratory for Applied Network Research and funded by the National Science Foundation. diff -u -r -N squid-3.2.0.16/tools/cachemgr.cgi.8.in squid-3.2.0.17/tools/cachemgr.cgi.8.in --- squid-3.2.0.16/tools/cachemgr.cgi.8.in 2012-03-07 15:42:55.000000000 +1300 +++ squid-3.2.0.17/tools/cachemgr.cgi.8.in 2012-04-13 01:43:26.000000000 +1200 @@ -49,7 +49,7 @@ program. . .SH AUTHOR -Derived from Harvest. Further developed by by numerous individuals from +Derived from Harvest. Further developed by numerous individuals from the internet community. Development is led by Duane Wessels of the National Laboratory for Applied Network Research and funded by the National Science Foundation.