diff -u -r -N squid-3.3.1/ChangeLog squid-3.3.2/ChangeLog --- squid-3.3.1/ChangeLog 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/ChangeLog 2013-03-02 15:36:58.000000000 +1300 @@ -1,3 +1,10 @@ +Changes to squid-3.3.2 (02 Mar 2013): + + - Bug 3781: Proxy Authentication not sent to cache_peer + - Bug 3794: MacOS: workaround compiler errors + - Bug 3720: Compile error in Solaris /OpenIndiana + - ... and all changes from squid 3.2.8 + Changes to squid-3.3.1 (09 Feb 2013): - Bug 3726: build errors with --disable-ssl @@ -43,6 +50,22 @@ - ... and many compile error fixes - ... and a very large amount of code polish for faster compilation +Changes to squid-3.2.8 (02 Mar 2013): + + - Bug 3767: tcp_outgoing_tos/mark ACLs do not obey acl_uses_indirect_client + - Bug 3763: diskd Error: no filename in shm buffer + - Bug 3752: objects that cannot be cached in memory are not cached on disk + - Bug 3753: Removes the domain from the cache_peer server pconn key + - Bug 3749: IDENT lookup using wrong ports to identify the user + - Bug 3723: tcp_outgoing_tos/mark broken for CONNECT requests + - Bug 3686: cache_dir max-size default fails + - Bug 3515: crash in FtpStateData::ftpTimeout + - Bug 3329: Quieten orphan Comm::Connection messages + - Make squid -z for cache_dir rock preserve the rock DB + - Fixed several server connect problems + - ... and some build issues on Solaris, OpenIndiana, MacOS X + - ... and some documentation and debugs polishing + Changes to squid-3.2.7 (01 Feb 2013): - Bug 3736: Floating point exception due to divide by zero diff -u -r -N squid-3.3.1/compat/xstrto.h squid-3.3.2/compat/xstrto.h --- squid-3.3.1/compat/xstrto.h 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/compat/xstrto.h 2013-03-02 15:36:58.000000000 +1300 @@ -1,6 +1,9 @@ #ifndef _SQUID_XSTRTO_H #define _SQUID_XSTRTO_H +// these functions are not used by the remaining Squid C code. +#if defined(__cplusplus) + #if HAVE_STDBOOL_H #include #endif @@ -27,4 +30,5 @@ bool xstrtoui(const char *s, char **end, unsigned int *value, unsigned int min, unsigned int max); +#endif /* __cplusplus */ #endif /* _SQUID_XSTRTO_H */ diff -u -r -N squid-3.3.1/configure squid-3.3.2/configure --- squid-3.3.1/configure 2013-02-09 20:30:57.000000000 +1300 +++ squid-3.3.2/configure 2013-03-02 15:38:12.000000000 +1300 @@ -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.3.1. +# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.3.2. # # Report bugs to . # @@ -575,8 +575,8 @@ # Identity of this package. PACKAGE_NAME='Squid Web Proxy' PACKAGE_TARNAME='squid' -PACKAGE_VERSION='3.3.1' -PACKAGE_STRING='Squid Web Proxy 3.3.1' +PACKAGE_VERSION='3.3.2' +PACKAGE_STRING='Squid Web Proxy 3.3.2' PACKAGE_BUGREPORT='http://bugs.squid-cache.org/' 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.3.1 to adapt to many kinds of systems. +\`configure' configures Squid Web Proxy 3.3.2 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.3.1:";; + short | recursive ) echo "Configuration of Squid Web Proxy 3.3.2:";; esac cat <<\_ACEOF @@ -2014,7 +2014,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Squid Web Proxy configure 3.3.1 +Squid Web Proxy configure 3.3.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -3110,7 +3110,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.3.1, which was +It was created by Squid Web Proxy $as_me 3.3.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3929,7 +3929,7 @@ # Define the identity of the package. PACKAGE='squid' - VERSION='3.3.1' + VERSION='3.3.2' cat >>confdefs.h <<_ACEOF @@ -31319,7 +31319,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.3.1, which was +This file was extended by Squid Web Proxy $as_me 3.3.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -31385,7 +31385,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.3.1 +Squid Web Proxy config.status 3.3.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff -u -r -N squid-3.3.1/configure.ac squid-3.3.2/configure.ac --- squid-3.3.1/configure.ac 2013-02-09 20:30:56.000000000 +1300 +++ squid-3.3.2/configure.ac 2013-03-02 15:38:12.000000000 +1300 @@ -1,4 +1,4 @@ -AC_INIT([Squid Web Proxy],[3.3.1],[http://bugs.squid-cache.org/],[squid]) +AC_INIT([Squid Web Proxy],[3.3.2],[http://bugs.squid-cache.org/],[squid]) AC_PREREQ(2.61) AC_CONFIG_HEADERS([include/autoconf.h]) AC_CONFIG_AUX_DIR(cfgaux) diff -u -r -N squid-3.3.1/helpers/basic_auth/DB/basic_db_auth.8 squid-3.3.2/helpers/basic_auth/DB/basic_db_auth.8 --- squid-3.3.1/helpers/basic_auth/DB/basic_db_auth.8 2013-02-09 20:47:59.000000000 +1300 +++ squid-3.3.2/helpers/basic_auth/DB/basic_db_auth.8 2013-03-02 16:01:15.000000000 +1300 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "BASIC_DB_AUTH 1" -.TH BASIC_DB_AUTH 1 "2013-02-09" "perl v5.10.1" "User Contributed Perl Documentation" +.TH BASIC_DB_AUTH 1 "2013-03-01" "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.3.1/helpers/external_acl/SQL_session/ext_sql_session_acl.8 squid-3.3.2/helpers/external_acl/SQL_session/ext_sql_session_acl.8 --- squid-3.3.1/helpers/external_acl/SQL_session/ext_sql_session_acl.8 2013-02-09 20:48:03.000000000 +1300 +++ squid-3.3.2/helpers/external_acl/SQL_session/ext_sql_session_acl.8 2013-03-02 16:01:20.000000000 +1300 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "EXT_SQL_SESSION_ACL 1" -.TH EXT_SQL_SESSION_ACL 1 "2013-02-09" "perl v5.10.1" "User Contributed Perl Documentation" +.TH EXT_SQL_SESSION_ACL 1 "2013-03-01" "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.3.1/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 squid-3.3.2/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 --- squid-3.3.1/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 2013-02-09 20:48:04.000000000 +1300 +++ squid-3.3.2/helpers/external_acl/wbinfo_group/ext_wbinfo_group_acl.8 2013-03-02 16:01:20.000000000 +1300 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "EXT_WBINFO_GROUP_ACL.PL.IN 1" -.TH EXT_WBINFO_GROUP_ACL.PL.IN 1 "2013-02-09" "perl v5.10.1" "User Contributed Perl Documentation" +.TH EXT_WBINFO_GROUP_ACL.PL.IN 1 "2013-03-01" "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.3.1/helpers/log_daemon/DB/log_db_daemon.8 squid-3.3.2/helpers/log_daemon/DB/log_db_daemon.8 --- squid-3.3.1/helpers/log_daemon/DB/log_db_daemon.8 2013-02-09 20:48:04.000000000 +1300 +++ squid-3.3.2/helpers/log_daemon/DB/log_db_daemon.8 2013-03-02 16:01:21.000000000 +1300 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "LOG_DB_DAEMON 1" -.TH LOG_DB_DAEMON 1 "2013-02-09" "perl v5.10.1" "User Contributed Perl Documentation" +.TH LOG_DB_DAEMON 1 "2013-03-01" "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.3.1/include/version.h squid-3.3.2/include/version.h --- squid-3.3.1/include/version.h 2013-02-09 20:30:57.000000000 +1300 +++ squid-3.3.2/include/version.h 2013-03-02 15:38:13.000000000 +1300 @@ -7,7 +7,7 @@ */ #ifndef SQUID_RELEASE_TIME -#define SQUID_RELEASE_TIME 1360394999 +#define SQUID_RELEASE_TIME 1362191814 #endif #ifndef APP_SHORTNAME diff -u -r -N squid-3.3.1/src/acl/DomainData.cc squid-3.3.2/src/acl/DomainData.cc --- squid-3.3.1/src/acl/DomainData.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/acl/DomainData.cc 2013-03-02 15:36:58.000000000 +1300 @@ -38,7 +38,7 @@ #include "cache_cf.h" #include "Debug.h" #include "wordlist.h" -#include "URL.h" +#include "src/URL.h" template inline void diff -u -r -N squid-3.3.1/src/acl/Url.cc squid-3.3.2/src/acl/Url.cc --- squid-3.3.1/src/acl/Url.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/acl/Url.cc 2013-03-02 15:36:58.000000000 +1300 @@ -37,7 +37,7 @@ #include "acl/Checklist.h" #include "acl/RegexData.h" #include "rfc1738.h" -#include "URL.h" +#include "src/URL.h" int ACLUrlStrategy::match (ACLData * &data, ACLFilledChecklist *checklist) diff -u -r -N squid-3.3.1/src/cache_cf.cc squid-3.3.2/src/cache_cf.cc --- squid-3.3.1/src/cache_cf.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/cache_cf.cc 2013-03-02 15:36:58.000000000 +1300 @@ -277,16 +277,23 @@ static void update_maxobjsize(void) { - int i; int64_t ms = -1; - for (i = 0; i < Config.cacheSwap.n_configured; ++i) { + // determine the maximum size object that can be stored to disk + for (int i = 0; i < Config.cacheSwap.n_configured; ++i) { assert (Config.cacheSwap.swapDirs[i].getRaw()); - if (dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())-> - max_objsize > ms) - ms = dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())->max_objsize; + const int64_t storeMax = dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())->maxObjectSize(); + if (ms < storeMax) + ms = storeMax; } + + // Ensure that we do not discard objects which could be stored only in memory. + // It is governed by maximum_object_size_in_memory (for now) + // TODO: update this to check each in-memory location (SMP and local memory limits differ) + if (ms < static_cast(Config.Store.maxInMemObjSize)) + ms = Config.Store.maxInMemObjSize; + store_maxobjsize = ms; } diff -u -r -N squid-3.3.1/src/cf.data.pre squid-3.3.2/src/cf.data.pre --- squid-3.3.1/src/cf.data.pre 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/cf.data.pre 2013-03-02 15:36:58.000000000 +1300 @@ -3061,7 +3061,7 @@ replacement policies. NOTE: if using the LFUDA replacement policy you should increase - the value of maximum_object_size above its default of 4096 KB to + the value of maximum_object_size above its default of 4 MB to to maximize the potential byte hit rate improvement of LFUDA. For more information about the GDSF and LFUDA cache replacement @@ -3159,6 +3159,12 @@ slot size is specified in bytes using the max-size option. See below for more info on the max-size option. + If possible, Squid using Rock Store creates a dedicated kid + process called "disker" to avoid blocking Squid worker(s) on disk + I/O. One disker kid is created for each rock cache_dir. Diskers + are created only when Squid, running in daemon mode, has support + for the IpcIo disk I/O module. + swap-timeout=msec: Squid will not start writing a miss to or reading a hit from disk if it estimates that the swap operation will take more than the specified number of milliseconds. By @@ -3260,14 +3266,18 @@ NAME: maximum_object_size COMMENT: (bytes) TYPE: b_int64_t -DEFAULT: 4096 KB +DEFAULT: 4 MB LOC: Config.Store.maxObjectSize DOC_START - Objects larger than this size will NOT be saved on disk. The - value is specified in kilobytes, and the default is 4MB. If - you wish to get a high BYTES hit ratio, you should probably + The default limit on size of objects stored to disk. + This size is used for cache_dir where max-size is not set. + The value is specified in bytes, and the default is 4 MB. + + If you wish to get a high BYTES hit ratio, you should probably increase this (one 32 MB object hit counts for 3200 10KB - hits). If you wish to increase speed more than your want to + hits). + + If you wish to increase hit ratio more than you want to save bandwidth you should leave this low. NOTE: if using the LFUDA replacement policy you should increase diff -u -r -N squid-3.3.1/src/comm/Connection.cc squid-3.3.2/src/comm/Connection.cc --- squid-3.3.1/src/comm/Connection.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/comm/Connection.cc 2013-03-02 15:36:58.000000000 +1300 @@ -29,8 +29,8 @@ Comm::Connection::~Connection() { if (fd >= 0) { - debugs(5, DBG_CRITICAL, "BUG #3329: Orphan Comm::Connection: " << *this); - debugs(5, DBG_CRITICAL, "NOTE: " << ++lost_conn << " Orphans since last started."); + debugs(5, 4, "BUG #3329: Orphan Comm::Connection: " << *this); + debugs(5, 4, "NOTE: " << ++lost_conn << " Orphans since last started."); close(); } diff -u -r -N squid-3.3.1/src/comm/ConnOpener.cc squid-3.3.2/src/comm/ConnOpener.cc --- squid-3.3.1/src/comm/ConnOpener.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/comm/ConnOpener.cc 2013-03-02 15:36:58.000000000 +1300 @@ -67,9 +67,11 @@ sendAnswer(COMM_ERR_CONNECT, 0, "Comm::ConnOpener::swanSong"); } + // did we abort with a temporary FD assigned? if (temporaryFd_ >= 0) closeFd(); + // did we abort while waiting between retries? if (calls_.sleep_) cancelSleep(); @@ -120,6 +122,7 @@ if (callback_->canceled()) { debugs(5, 4, conn_ << " not calling canceled " << *callback_ << " [" << callback_->id << ']' ); + // TODO save the pconn to the pconnPool ? } else { typedef CommConnectCbParams Params; Params ¶ms = GetCommParams(callback_); diff -u -r -N squid-3.3.1/src/DiskIO/DiskDaemon/diskd.cc squid-3.3.2/src/DiskIO/DiskDaemon/diskd.cc --- squid-3.3.1/src/DiskIO/DiskDaemon/diskd.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/DiskIO/DiskDaemon/diskd.cc 2013-03-02 15:36:58.000000000 +1300 @@ -264,7 +264,7 @@ if (s->shm_offset > -1) buf = shmbuf + s->shm_offset; - else { + else if (r->mtype != _MQD_CLOSE) { fprintf(stderr, "%d UNLNK id(%u) Error: no filename in shm buffer\n", (int) mypid, s->id); return; } diff -u -r -N squid-3.3.1/src/fde.cc squid-3.3.2/src/fde.cc --- squid-3.3.1/src/fde.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/fde.cc 2013-03-02 15:36:58.000000000 +1300 @@ -38,6 +38,8 @@ #include "SquidTime.h" #include "Store.h" +fde *fde::Table = NULL; + bool fde::readPending(int fdNumber) { diff -u -r -N squid-3.3.1/src/fde.h squid-3.3.2/src/fde.h --- squid-3.3.1/src/fde.h 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/fde.h 2013-03-02 15:36:58.000000000 +1300 @@ -73,6 +73,10 @@ void noteUse(PconnPool *); public: + + /// global table of FD and their state. + static fde* Table; + unsigned int type; unsigned short remote_port; @@ -193,6 +197,8 @@ } }; +#define fd_table fde::Table + int fdNFree(void); #define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len) diff -u -r -N squid-3.3.1/src/forward.cc squid-3.3.2/src/forward.cc --- squid-3.3.1/src/forward.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/forward.cc 2013-03-02 15:36:58.000000000 +1300 @@ -1002,12 +1002,9 @@ } // Use pconn to avoid opening a new connection. - const char *host; - if (serverDestinations[0]->getPeer()) { - host = serverDestinations[0]->getPeer()->host; - } else { + const char *host = NULL; + if (!serverDestinations[0]->getPeer()) host = request->GetHost(); - } Comm::ConnectionPointer temp; // Avoid pconns after races so that the same client does not suffer twice. @@ -1072,7 +1069,8 @@ calls.connector = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this)); Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], calls.connector, ctimeout); - cs->setHost(host); + if (host) + cs->setHost(host); AsyncJob::Start(cs); } @@ -1322,7 +1320,7 @@ FwdState::pconnPush(Comm::ConnectionPointer &conn, const char *domain) { if (conn->getPeer()) { - fwdPconnPool->push(conn, conn->getPeer()->name); + fwdPconnPool->push(conn, NULL); } else { fwdPconnPool->push(conn, domain); } diff -u -r -N squid-3.3.1/src/fs/rock/RockIoState.cc squid-3.3.2/src/fs/rock/RockIoState.cc --- squid-3.3.1/src/fs/rock/RockIoState.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/fs/rock/RockIoState.cc 2013-03-02 15:36:58.000000000 +1300 @@ -24,7 +24,7 @@ { e = anEntry; // swap_filen, swap_dirn, diskOffset, and payloadEnd are set by the caller - slotSize = dir->max_objsize; + slotSize = dir->maxObjectSize(); file_callback = cbFile; callback = cbIo; callback_data = cbdataReference(data); diff -u -r -N squid-3.3.1/src/globals.h squid-3.3.2/src/globals.h --- squid-3.3.1/src/globals.h 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/globals.h 2013-03-02 15:36:58.000000000 +1300 @@ -60,8 +60,6 @@ extern const char *pingStatusStr[]; extern const char *storeStatusStr[]; extern const char *swapStatusStr[]; -class fde; -extern fde *fd_table; /* NULL */ extern int Biggest_FD; /* -1 */ extern int Number_FD; /* 0 */ extern int Opening_FD; /* 0 */ diff -u -r -N squid-3.3.1/src/http.cc squid-3.3.2/src/http.cc --- squid-3.3.1/src/http.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/http.cc 2013-03-02 15:36:58.000000000 +1300 @@ -432,7 +432,7 @@ // HTTPbis pt6 section 3.2: a response CC:s-maxage is present } else if (rep->cache_control->sMaxAge()) { - debugs(22, 3, HERE << " Authenticated but server reply Cache-Control:s-maxage"); + debugs(22, 3, HERE << "Authenticated but server reply Cache-Control:s-maxage"); mayStore = true; } @@ -1457,7 +1457,7 @@ request->clientConnectionManager->pinConnection(serverConnection, request, _peer, (request->flags.connectionAuth != 0)); } else { - fwd->pconnPush(serverConnection, request->peer_host ? request->peer_host : request->GetHost()); + fwd->pconnPush(serverConnection, request->GetHost()); } serverConnection = NULL; @@ -2131,18 +2131,8 @@ Dialer, this, HttpStateData::wroteLast); } - if (_peer != NULL) { - if (_peer->options.originserver) { - flags.proxying = false; - flags.originpeer = true; - } else { - flags.proxying = false; - flags.originpeer = false; - } - } else { - flags.proxying = false; - flags.originpeer = false; - } + flags.originpeer = (_peer != NULL && _peer->options.originserver); + flags.proxying = (_peer != NULL && !flags.originpeer); /* * Is keep-alive okay for all request methods? diff -u -r -N squid-3.3.1/src/Makefile.am squid-3.3.2/src/Makefile.am --- squid-3.3.1/src/Makefile.am 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/Makefile.am 2013-03-02 15:36:58.000000000 +1300 @@ -1628,6 +1628,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ FileMap.h \ filemap.cc \ HttpBody.h \ @@ -2868,6 +2870,7 @@ tests/stub_DiskIOModule.cc \ tests/stub_errorpage.cc \ fd.h \ + fde.h \ tests/stub_fd.cc \ tests/stub_helper.cc \ tests/stub_HelperChildConfig.cc \ @@ -3026,6 +3029,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ client_db.h \ disk.h \ disk.cc \ @@ -3189,6 +3194,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ FileMap.h \ filemap.cc \ HttpHeaderFieldStat.h \ @@ -3349,6 +3356,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ disk.h \ disk.cc \ FileMap.h \ diff -u -r -N squid-3.3.1/src/Makefile.in squid-3.3.2/src/Makefile.in --- squid-3.3.1/src/Makefile.in 2013-02-09 20:30:35.000000000 +1300 +++ squid-3.3.2/src/Makefile.in 2013-03-02 15:37:46.000000000 +1300 @@ -603,19 +603,20 @@ tests/stub_internal.cc tests/stub_ipc.cc tests/stub_pconn.cc \ store_rebuild.h tests/stub_store_rebuild.cc \ tests/stub_store_stats.cc fatal.h tests/stub_fatal.cc fd.h \ - fd.cc disk.h disk.cc FileMap.h filemap.cc HttpBody.h \ - HttpBody.cc HttpReply.cc HttpStatusLine.cc int.h int.cc \ - SquidList.h SquidList.cc MemObject.cc StoreSwapLogData.cc \ - StoreIOState.cc StoreMeta.cc StoreMetaMD5.cc StoreMetaSTD.cc \ - StoreMetaSTDLFS.cc StoreMetaUnpacker.cc StoreMetaURL.cc \ - StoreMetaVary.cc StoreFileSystem.cc store_io.cc \ - store_swapout.cc store_swapmeta.cc unlinkd.h unlinkd.cc \ - win32.cc event.cc CommonPool.h CompositePoolNode.h \ - delay_pools.cc DelayId.cc DelayId.h DelayIdComposite.h \ - DelayBucket.cc DelayBucket.h DelayConfig.cc DelayConfig.h \ - DelayPool.cc DelayPool.h DelayPools.h DelaySpec.cc DelaySpec.h \ - DelayTagged.cc DelayTagged.h DelayUser.cc DelayUser.h \ - DelayVector.cc DelayVector.h NullDelayId.cc NullDelayId.h \ + fd.cc fde.h fde.cc disk.h disk.cc FileMap.h filemap.cc \ + HttpBody.h HttpBody.cc HttpReply.cc HttpStatusLine.cc int.h \ + int.cc SquidList.h SquidList.cc MemObject.cc \ + StoreSwapLogData.cc StoreIOState.cc StoreMeta.cc \ + StoreMetaMD5.cc StoreMetaSTD.cc StoreMetaSTDLFS.cc \ + StoreMetaUnpacker.cc StoreMetaURL.cc StoreMetaVary.cc \ + StoreFileSystem.cc store_io.cc store_swapout.cc \ + store_swapmeta.cc unlinkd.h unlinkd.cc win32.cc event.cc \ + CommonPool.h CompositePoolNode.h delay_pools.cc DelayId.cc \ + DelayId.h DelayIdComposite.h DelayBucket.cc DelayBucket.h \ + DelayConfig.cc DelayConfig.h DelayPool.cc DelayPool.h \ + DelayPools.h DelaySpec.cc DelaySpec.h DelayTagged.cc \ + DelayTagged.h DelayUser.cc DelayUser.h DelayVector.cc \ + DelayVector.h NullDelayId.cc NullDelayId.h \ ClientDelayConfig.cc ClientDelayConfig.h CacheDigest.h \ CacheDigest.cc ConfigParser.cc EventLoop.cc HttpMsg.cc \ RemovalPolicy.cc store_dir.cc repl_modules.h store.cc \ @@ -649,7 +650,7 @@ tests/stub_internal.$(OBJEXT) tests/stub_ipc.$(OBJEXT) \ tests/stub_pconn.$(OBJEXT) tests/stub_store_rebuild.$(OBJEXT) \ tests/stub_store_stats.$(OBJEXT) tests/stub_fatal.$(OBJEXT) \ - fd.$(OBJEXT) disk.$(OBJEXT) filemap.$(OBJEXT) \ + fd.$(OBJEXT) fde.$(OBJEXT) disk.$(OBJEXT) filemap.$(OBJEXT) \ HttpBody.$(OBJEXT) HttpReply.$(OBJEXT) \ HttpStatusLine.$(OBJEXT) int.$(OBJEXT) SquidList.$(OBJEXT) \ MemObject.$(OBJEXT) StoreSwapLogData.$(OBJEXT) \ @@ -704,26 +705,26 @@ DiskIO/WriteRequest.h DiskIO/DiskFile.h \ DiskIO/DiskIOStrategy.h DiskIO/IORequestor.h \ DiskIO/DiskIOModule.h disk.h disk.cc ETag.cc EventLoop.cc \ - event.cc fatal.h tests/stub_fatal.cc fd.h fd.cc FileMap.h \ - filemap.cc HttpBody.h HttpBody.cc HttpHeaderFieldStat.h \ - HttpHdrCc.h HttpHdrCc.cc HttpHdrCc.cci HttpHdrContRange.cc \ - HttpHdrSc.cc HttpHdrScTarget.cc HttpHdrRange.cc \ - HttpHeaderFieldInfo.h HttpHeaderTools.h HttpHeaderTools.cc \ - HttpHeader.h HttpHeader.cc HttpMsg.cc HttpReply.cc \ - HttpRequestMethod.cc HttpStatusLine.cc int.h int.cc \ - SquidList.h SquidList.cc MemBuf.cc MemObject.cc mem_node.cc \ - Mem.h mem.cc Packer.cc Parsing.cc refresh.h refresh.cc \ - RemovalPolicy.cc RequestFlags.h RequestFlags.cc StatCounters.h \ - StatCounters.cc StatHist.h tests/stub_StatHist.cc stmem.cc \ - StoreFileSystem.cc StoreIOState.cc StoreMeta.cc \ - StoreMetaMD5.cc StoreMetaSTD.cc StoreMetaSTDLFS.cc \ - StoreMetaUnpacker.cc StoreMetaURL.cc StoreMetaVary.cc \ - StoreSwapLogData.cc store_dir.cc store_io.cc store_key_md5.h \ - store_key_md5.cc store_swapout.cc store_swapmeta.cc \ - repl_modules.h store.cc String.cc StrList.h StrList.cc \ - SwapDir.cc log/access_log.h tests/stub_access_log.cc \ - tests/stub_acl.cc cache_cf.h YesNoNone.h \ - tests/stub_cache_cf.cc tests/stub_cache_manager.cc \ + event.cc fatal.h tests/stub_fatal.cc fd.h fd.cc fde.h fde.cc \ + FileMap.h filemap.cc HttpBody.h HttpBody.cc \ + HttpHeaderFieldStat.h HttpHdrCc.h HttpHdrCc.cc HttpHdrCc.cci \ + HttpHdrContRange.cc HttpHdrSc.cc HttpHdrScTarget.cc \ + HttpHdrRange.cc HttpHeaderFieldInfo.h HttpHeaderTools.h \ + HttpHeaderTools.cc HttpHeader.h HttpHeader.cc HttpMsg.cc \ + HttpReply.cc HttpRequestMethod.cc HttpStatusLine.cc int.h \ + int.cc SquidList.h SquidList.cc MemBuf.cc MemObject.cc \ + mem_node.cc Mem.h mem.cc Packer.cc Parsing.cc refresh.h \ + refresh.cc RemovalPolicy.cc RequestFlags.h RequestFlags.cc \ + StatCounters.h StatCounters.cc StatHist.h \ + tests/stub_StatHist.cc stmem.cc StoreFileSystem.cc \ + StoreIOState.cc StoreMeta.cc StoreMetaMD5.cc StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc StoreMetaUnpacker.cc StoreMetaURL.cc \ + StoreMetaVary.cc StoreSwapLogData.cc store_dir.cc store_io.cc \ + store_key_md5.h store_key_md5.cc store_swapout.cc \ + store_swapmeta.cc repl_modules.h store.cc String.cc StrList.h \ + StrList.cc SwapDir.cc log/access_log.h \ + tests/stub_access_log.cc tests/stub_acl.cc cache_cf.h \ + YesNoNone.h tests/stub_cache_cf.cc tests/stub_cache_manager.cc \ tests/stub_client_db.cc client_side_request.h \ tests/stub_client_side_request.cc tests/stub_debug.cc \ tests/stub_errorpage.cc tests/stub_helper.cc \ @@ -744,11 +745,12 @@ ConfigOption.$(OBJEXT) ConfigParser.$(OBJEXT) $(am__objects_6) \ $(am__objects_7) disk.$(OBJEXT) ETag.$(OBJEXT) \ EventLoop.$(OBJEXT) event.$(OBJEXT) tests/stub_fatal.$(OBJEXT) \ - fd.$(OBJEXT) filemap.$(OBJEXT) HttpBody.$(OBJEXT) \ - HttpHdrCc.$(OBJEXT) HttpHdrContRange.$(OBJEXT) \ - HttpHdrSc.$(OBJEXT) HttpHdrScTarget.$(OBJEXT) \ - HttpHdrRange.$(OBJEXT) HttpHeaderTools.$(OBJEXT) \ - HttpHeader.$(OBJEXT) HttpMsg.$(OBJEXT) HttpReply.$(OBJEXT) \ + fd.$(OBJEXT) fde.$(OBJEXT) filemap.$(OBJEXT) \ + HttpBody.$(OBJEXT) HttpHdrCc.$(OBJEXT) \ + HttpHdrContRange.$(OBJEXT) HttpHdrSc.$(OBJEXT) \ + HttpHdrScTarget.$(OBJEXT) HttpHdrRange.$(OBJEXT) \ + HttpHeaderTools.$(OBJEXT) HttpHeader.$(OBJEXT) \ + HttpMsg.$(OBJEXT) HttpReply.$(OBJEXT) \ HttpRequestMethod.$(OBJEXT) HttpStatusLine.$(OBJEXT) \ int.$(OBJEXT) SquidList.$(OBJEXT) MemBuf.$(OBJEXT) \ MemObject.$(OBJEXT) mem_node.$(OBJEXT) mem.$(OBJEXT) \ @@ -1277,13 +1279,14 @@ am__tests_testRock_SOURCES_DIST = cbdata.cc CacheDigest.h \ CacheDigest.cc ConfigOption.cc ConfigParser.cc disk.h disk.cc \ ETag.cc EventLoop.cc event.cc fatal.h tests/stub_fatal.cc fd.h \ - fd.cc FileMap.h filemap.cc HttpHeaderFieldStat.h HttpBody.h \ - HttpBody.cc HttpHdrCc.cc HttpHdrContRange.cc HttpHdrRange.cc \ - HttpHdrSc.cc HttpHdrScTarget.cc HttpHeader.h HttpHeader.cc \ - HttpHeaderFieldInfo.h HttpHeaderTools.h HttpHeaderTools.cc \ - HttpMsg.cc HttpReply.cc HttpRequestMethod.cc HttpStatusLine.cc \ - int.h int.cc SquidList.h SquidList.cc Mem.h mem.cc MemBuf.cc \ - MemObject.cc mem_node.cc Packer.cc Parsing.cc RemovalPolicy.cc \ + fd.cc fde.h fde.cc FileMap.h filemap.cc HttpHeaderFieldStat.h \ + HttpBody.h HttpBody.cc HttpHdrCc.cc HttpHdrContRange.cc \ + HttpHdrRange.cc HttpHdrSc.cc HttpHdrScTarget.cc HttpHeader.h \ + HttpHeader.cc HttpHeaderFieldInfo.h HttpHeaderTools.h \ + HttpHeaderTools.cc HttpMsg.cc HttpReply.cc \ + HttpRequestMethod.cc HttpStatusLine.cc int.h int.cc \ + SquidList.h SquidList.cc Mem.h mem.cc MemBuf.cc MemObject.cc \ + mem_node.cc Packer.cc Parsing.cc RemovalPolicy.cc \ RequestFlags.cc RequestFlags.h StatCounters.h StatCounters.cc \ StatHist.h tests/stub_StatHist.cc stmem.cc repl_modules.h \ store.cc StoreFileSystem.cc StoreIOState.cc StoreMeta.cc \ @@ -1321,8 +1324,8 @@ am_tests_testRock_OBJECTS = cbdata.$(OBJEXT) CacheDigest.$(OBJEXT) \ ConfigOption.$(OBJEXT) ConfigParser.$(OBJEXT) disk.$(OBJEXT) \ ETag.$(OBJEXT) EventLoop.$(OBJEXT) event.$(OBJEXT) \ - tests/stub_fatal.$(OBJEXT) fd.$(OBJEXT) filemap.$(OBJEXT) \ - HttpBody.$(OBJEXT) HttpHdrCc.$(OBJEXT) \ + tests/stub_fatal.$(OBJEXT) fd.$(OBJEXT) fde.$(OBJEXT) \ + filemap.$(OBJEXT) HttpBody.$(OBJEXT) HttpHdrCc.$(OBJEXT) \ HttpHdrContRange.$(OBJEXT) HttpHdrRange.$(OBJEXT) \ HttpHdrSc.$(OBJEXT) HttpHdrScTarget.$(OBJEXT) \ HttpHeader.$(OBJEXT) HttpHeaderTools.$(OBJEXT) \ @@ -1414,7 +1417,7 @@ cache_cf.h YesNoNone.h tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc tests/stub_client_side_request.cc \ tests/stub_comm.cc tests/stub_debug.cc \ - tests/stub_DiskIOModule.cc tests/stub_errorpage.cc fd.h \ + tests/stub_DiskIOModule.cc tests/stub_errorpage.cc fd.h fde.h \ tests/stub_fd.cc tests/stub_helper.cc \ tests/stub_HelperChildConfig.cc tests/stub_http.cc \ tests/stub_libformat.cc HttpBody.h HttpBody.cc \ @@ -1624,20 +1627,20 @@ internal.h tests/stub_internal.cc tests/stub_libformat.cc \ store_rebuild.h tests/stub_store_rebuild.cc \ tests/stub_store_stats.cc fatal.h tests/stub_fatal.cc fd.h \ - fd.cc client_db.h disk.h disk.cc FileMap.h filemap.cc \ - HttpBody.h HttpBody.cc HttpReply.cc HttpStatusLine.cc int.h \ - int.cc RequestFlags.h RequestFlags.cc SquidList.h SquidList.cc \ - MemObject.cc StoreSwapLogData.cc StoreIOState.cc StoreMeta.cc \ - StoreMetaMD5.cc StoreMetaSTD.cc StoreMetaSTDLFS.cc \ - StoreMetaUnpacker.cc StoreMetaURL.cc StoreMetaVary.cc \ - StoreFileSystem.cc store_io.cc store_swapout.cc \ - store_swapmeta.cc unlinkd.h unlinkd.cc win32.cc event.cc \ - CommonPool.h CompositePoolNode.h delay_pools.cc DelayId.cc \ - DelayId.h DelayIdComposite.h DelayBucket.cc DelayBucket.h \ - DelayConfig.cc DelayConfig.h DelayPool.cc DelayPool.h \ - DelayPools.h DelaySpec.cc DelaySpec.h DelayTagged.cc \ - DelayTagged.h DelayUser.cc DelayUser.h DelayVector.cc \ - DelayVector.h NullDelayId.cc NullDelayId.h \ + fd.cc fde.h fde.cc client_db.h disk.h disk.cc FileMap.h \ + filemap.cc HttpBody.h HttpBody.cc HttpReply.cc \ + HttpStatusLine.cc int.h int.cc RequestFlags.h RequestFlags.cc \ + SquidList.h SquidList.cc MemObject.cc StoreSwapLogData.cc \ + StoreIOState.cc StoreMeta.cc StoreMetaMD5.cc StoreMetaSTD.cc \ + StoreMetaSTDLFS.cc StoreMetaUnpacker.cc StoreMetaURL.cc \ + StoreMetaVary.cc StoreFileSystem.cc store_io.cc \ + store_swapout.cc store_swapmeta.cc unlinkd.h unlinkd.cc \ + win32.cc event.cc CommonPool.h CompositePoolNode.h \ + delay_pools.cc DelayId.cc DelayId.h DelayIdComposite.h \ + DelayBucket.cc DelayBucket.h DelayConfig.cc DelayConfig.h \ + DelayPool.cc DelayPool.h DelayPools.h DelaySpec.cc DelaySpec.h \ + DelayTagged.cc DelayTagged.h DelayUser.cc DelayUser.h \ + DelayVector.cc DelayVector.h NullDelayId.cc NullDelayId.h \ ClientDelayConfig.cc ClientDelayConfig.h CacheDigest.h \ CacheDigest.cc ConfigParser.cc EventLoop.cc HttpMsg.cc \ RemovalPolicy.cc store_dir.cc repl_modules.h store.cc \ @@ -1672,7 +1675,7 @@ tests/stub_internal.$(OBJEXT) tests/stub_libformat.$(OBJEXT) \ tests/stub_store_rebuild.$(OBJEXT) \ tests/stub_store_stats.$(OBJEXT) tests/stub_fatal.$(OBJEXT) \ - fd.$(OBJEXT) disk.$(OBJEXT) filemap.$(OBJEXT) \ + fd.$(OBJEXT) fde.$(OBJEXT) disk.$(OBJEXT) filemap.$(OBJEXT) \ HttpBody.$(OBJEXT) HttpReply.$(OBJEXT) \ HttpStatusLine.$(OBJEXT) int.$(OBJEXT) RequestFlags.$(OBJEXT) \ SquidList.$(OBJEXT) MemObject.$(OBJEXT) \ @@ -3369,6 +3372,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ FileMap.h \ filemap.cc \ HttpBody.h \ @@ -4621,6 +4626,7 @@ tests/stub_DiskIOModule.cc \ tests/stub_errorpage.cc \ fd.h \ + fde.h \ tests/stub_fd.cc \ tests/stub_helper.cc \ tests/stub_HelperChildConfig.cc \ @@ -4780,6 +4786,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ client_db.h \ disk.h \ disk.cc \ @@ -4945,6 +4953,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ FileMap.h \ filemap.cc \ HttpHeaderFieldStat.h \ @@ -5108,6 +5118,8 @@ tests/stub_fatal.cc \ fd.h \ fd.cc \ + fde.h \ + fde.cc \ disk.h \ disk.cc \ FileMap.h \ diff -u -r -N squid-3.3.1/src/store.cc squid-3.3.2/src/store.cc --- squid-3.3.1/src/store.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/store.cc 2013-03-02 15:36:58.000000000 +1300 @@ -998,9 +998,8 @@ ++store_check_cachable_hist.no.negative_cached; return 0; /* avoid release call below */ } else if ((getReply()->content_length > 0 && - getReply()->content_length - > Config.Store.maxObjectSize) || - mem_obj->endOffset() > Config.Store.maxObjectSize) { + getReply()->content_length > store_maxobjsize) || + mem_obj->endOffset() > store_maxobjsize) { debugs(20, 2, "StoreEntry::checkCachable: NO: too big"); ++store_check_cachable_hist.no.too_big; } else if (checkTooSmall()) { diff -u -r -N squid-3.3.1/src/store_dir.cc squid-3.3.2/src/store_dir.cc --- squid-3.3.1/src/store_dir.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/store_dir.cc 2013-03-02 15:36:58.000000000 +1300 @@ -277,10 +277,10 @@ /* If the load is equal, then look in more details */ if (load == least_load) { - /* closest max_objsize fit */ + /* closest max-size fit */ if (least_objsize != -1) - if (SD->max_objsize > least_objsize || SD->max_objsize == -1) + if (SD->maxObjectSize() > least_objsize) continue; /* most free */ @@ -289,7 +289,7 @@ } least_load = load; - least_objsize = SD->max_objsize; + least_objsize = SD->maxObjectSize(); most_free = cur_free; dirn = i; } diff -u -r -N squid-3.3.1/src/store_swapout.cc squid-3.3.2/src/store_swapout.cc --- squid-3.3.1/src/store_swapout.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/store_swapout.cc 2013-03-02 15:36:58.000000000 +1300 @@ -200,7 +200,7 @@ Store::Root().maybeTrimMemory(*this, weAreOrMayBeSwappingOut); - if (!weAreOrMayBeSwappingOut) + if (mem_obj->swapout.decision != MemObject::SwapOut::swPossible) return; // nothing else to do // Aborted entries have STORE_OK, but swapoutPossible rejects them. Thus, @@ -360,8 +360,6 @@ bool StoreEntry::mayStartSwapOut() { - dlink_node *node; - // must be checked in the caller assert(!EBIT_TEST(flags, ENTRY_ABORTED)); assert(!swappingOut()); @@ -403,6 +401,18 @@ return false; } + if (mem_obj->inmem_lo > 0) { + debugs(20, 3, "storeSwapOut: (inmem_lo > 0) imem_lo:" << mem_obj->inmem_lo); + decision = MemObject::SwapOut::swImpossible; + return false; + } + + if (!mem_obj->isContiguous()) { + debugs(20, 3, "storeSwapOut: not Contiguous"); + decision = MemObject::SwapOut::swImpossible; + return false; + } + // check cache_dir max-size limit if all cache_dirs have it if (store_maxobjsize >= 0) { // TODO: add estimated store metadata size to be conservative @@ -426,69 +436,25 @@ return false; // already does not fit and may only get bigger } - // prevent default swPossible answer for yet unknown length - if (expectedEnd < 0) { - debugs(20, 3, HERE << "wait for more info: " << - store_maxobjsize); - return false; // may fit later, but will be rejected now - } - - if (store_status != STORE_OK) { - const int64_t maxKnownSize = expectedEnd < 0 ? - mem_obj->availableForSwapOut() : expectedEnd; + // prevent final default swPossible answer for yet unknown length + if (expectedEnd < 0 && store_status != STORE_OK) { + const int64_t maxKnownSize = mem_obj->availableForSwapOut(); debugs(20, 7, HERE << "maxKnownSize= " << maxKnownSize); - if (maxKnownSize < store_maxobjsize) { - /* - * NOTE: the store_maxobjsize here is the max of optional - * max-size values from 'cache_dir' lines. It is not the - * same as 'maximum_object_size'. By default, store_maxobjsize - * will be set to -1. However, I am worried that this - * deferance may consume a lot of memory in some cases. - * Should we add an option to limit this memory consumption? - */ - debugs(20, 5, HERE << "Deferring swapout start for " << - (store_maxobjsize - maxKnownSize) << " bytes"); - return false; - } - } - } - - if (mem_obj->inmem_lo > 0) { - debugs(20, 3, "storeSwapOut: (inmem_lo > 0) imem_lo:" << mem_obj->inmem_lo); - decision = MemObject::SwapOut::swImpossible; - return false; - } - - /* - * If there are DISK clients, we must write to disk - * even if its not cachable - * RBC: Surely we should not create disk client on non cacheable objects? - * therefore this should be an assert? - * RBC 20030708: We can use disk to avoid mem races, so this shouldn't be - * an assert. - * - * XXX: Not clear what "mem races" the above refers to, especially when - * dealing with non-cachable objects that cannot have multiple clients. - * - * XXX: If STORE_DISK_CLIENT needs SwapOut::swPossible, we have to check - * for that flag earlier, but forcing swapping may contradict max-size or - * other swapability restrictions. Change storeClientType() and/or its - * callers to take swap-in availability into account. - */ - for (node = mem_obj->clients.head; node; node = node->next) { - if (((store_client *) node->data)->getType() == STORE_DISK_CLIENT) { - debugs(20, 3, HERE << "DISK client found"); - decision = MemObject::SwapOut::swPossible; - return true; + /* + * NOTE: the store_maxobjsize here is the global maximum + * size of object cacheable in any of Squid cache stores + * both disk and memory stores. + * + * However, I am worried that this + * deferance may consume a lot of memory in some cases. + * Should we add an option to limit this memory consumption? + */ + debugs(20, 5, HERE << "Deferring swapout start for " << + (store_maxobjsize - maxKnownSize) << " bytes"); + return true; // may still fit, but no final decision yet } } - if (!mem_obj->isContiguous()) { - debugs(20, 3, "storeSwapOut: not Contiguous"); - decision = MemObject::SwapOut::swImpossible; - return false; - } - decision = MemObject::SwapOut::swPossible; return true; } diff -u -r -N squid-3.3.1/src/SwapDir.cc squid-3.3.2/src/SwapDir.cc --- squid-3.3.1/src/SwapDir.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/SwapDir.cc 2013-03-02 15:36:58.000000000 +1300 @@ -42,8 +42,8 @@ #include "tools.h" SwapDir::SwapDir(char const *aType): theType(aType), - max_size(0), - path(NULL), index(-1), disker(-1), min_objsize(0), max_objsize (-1), + max_size(0), min_objsize(0), max_objsize (-1), + path(NULL), index(-1), disker(-1), repl(NULL), removals(0), scanned(0), cleanLog(NULL) { @@ -114,6 +114,39 @@ return ((maxSize() * Config.Swap.lowWaterMark) / 100); } +int64_t +SwapDir::maxObjectSize() const +{ + // per-store max-size=N value is authoritative + if (max_objsize > -1) + return max_objsize; + + // store with no individual max limit is limited by configured maximum_object_size + // or the total store size, whichever is smaller + return min(static_cast(maxSize()), Config.Store.maxObjectSize); +} + +void +SwapDir::maxObjectSize(int64_t newMax) +{ + // negative values mean no limit (-1) + if (newMax < 0) { + max_objsize = -1; // set explicitly in case it had a non-default value previously + return; + } + + // prohibit values greater than total storage area size + // but set max_objsize to the maximum allowed to override maximum_object_size global config + if (static_cast(newMax) > maxSize()) { + debugs(47, DBG_PARSE_NOTE(2), "WARNING: Ignoring 'max-size' option for " << path << + " which is larger than total cache_dir size of " << maxSize() << " bytes."); + max_objsize = maxSize(); + return; + } + + max_objsize = newMax; +} + void SwapDir::reference(StoreEntry &) {} diff -u -r -N squid-3.3.1/src/SwapDir.h squid-3.3.2/src/SwapDir.h --- squid-3.3.1/src/SwapDir.h 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/SwapDir.h 2013-03-02 15:36:58.000000000 +1300 @@ -148,7 +148,13 @@ virtual uint64_t minSize() const; - virtual int64_t maxObjectSize() const { return max_objsize; } + /// The maximum size of object which may be stored here. + /// Larger objects will not be added and may be purged. + virtual int64_t maxObjectSize() const; + + /// configure the maximum object size for this storage area. + /// May be any size up to the total storage area. + void maxObjectSize(int64_t newMax); virtual void getStats(StoreInfoStats &stats) const; virtual void stat (StoreEntry &anEntry) const; @@ -180,13 +186,13 @@ protected: uint64_t max_size; ///< maximum allocatable size of the storage area + int64_t min_objsize; ///< minimum size of any object stored here (-1 for no limit) + int64_t max_objsize; ///< maximum size of any object stored here (-1 for no limit) public: char *path; int index; /* This entry's index into the swapDirs array */ int disker; ///< disker kid id dedicated to this SwapDir or -1 - int64_t min_objsize; - int64_t max_objsize; RemovalPolicy *repl; int removals; int scanned; diff -u -r -N squid-3.3.1/src/tests/stub_fd.cc squid-3.3.2/src/tests/stub_fd.cc --- squid-3.3.1/src/tests/stub_fd.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/tests/stub_fd.cc 2013-03-02 15:36:58.000000000 +1300 @@ -4,6 +4,8 @@ #define STUB_API "fd.cc" #include "tests/STUB.h" +fde *fde::Table = NULL; + int fdNFree(void) STUB_RETVAL(-1) void fd_open(int fd, unsigned int type, const char *desc) STUB void fd_close(int fd) STUB diff -u -r -N squid-3.3.1/src/tests/testCoss.cc squid-3.3.2/src/tests/testCoss.cc --- squid-3.3.1/src/tests/testCoss.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/tests/testCoss.cc 2013-03-02 15:36:58.000000000 +1300 @@ -18,7 +18,7 @@ #include #endif -#define TESTDIR "testCoss__testCossSearch" +#define TESTDIR "testCoss_Store" CPPUNIT_TEST_SUITE_REGISTRATION( testCoss ); diff -u -r -N squid-3.3.1/src/tests/testRock.cc squid-3.3.2/src/tests/testRock.cc --- squid-3.3.1/src/tests/testRock.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/tests/testRock.cc 2013-03-02 15:36:58.000000000 +1300 @@ -27,7 +27,7 @@ #include #endif -#define TESTDIR "testRock__testRockSearch" +#define TESTDIR "testRock_Store" CPPUNIT_TEST_SUITE_REGISTRATION( testRock ); @@ -71,6 +71,7 @@ strtok(config_line, w_space); store->parse(0, path); + store_maxobjsize = 1024*1024*2; safe_free(path); @@ -179,8 +180,7 @@ StoreEntry *const pe = storeCreateEntry(url, "dummy log url", flags, METHOD_GET); HttpReply *const rep = const_cast(pe->getReply()); - rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", - -1, -1, squid_curtime + 100000); + rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); pe->setPublicKey(); diff -u -r -N squid-3.3.1/src/tests/testUfs.cc squid-3.3.2/src/tests/testUfs.cc --- squid-3.3.1/src/tests/testUfs.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/tests/testUfs.cc 2013-03-02 15:36:58.000000000 +1300 @@ -19,7 +19,7 @@ #include #endif -#define TESTDIR "testUfs__testUfsSearch" +#define TESTDIR "testUfs_Store" CPPUNIT_TEST_SUITE_REGISTRATION( testUfs ); @@ -111,6 +111,7 @@ strtok(config_line, w_space); aStore->parse(0, path); + store_maxobjsize = 1024*1024*2; safe_free(path); @@ -145,7 +146,7 @@ flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const - rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); + rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); pe->setPublicKey(); diff -u -r -N squid-3.3.1/src/tools.cc squid-3.3.2/src/tools.cc --- squid-3.3.1/src/tools.cc 2013-02-09 20:30:01.000000000 +1300 +++ squid-3.3.2/src/tools.cc 2013-03-02 15:36:58.000000000 +1300 @@ -127,28 +127,27 @@ { FILE *fp = NULL; static char command[256]; -#if HAVE_MKSTEMP + const mode_t prev_umask=umask(S_IRWXU); + +#if HAVE_MKSTEMP char filename[] = "/tmp/squid-XXXXXX"; int tfd = mkstemp(filename); - - if (tfd < 0) + if (tfd < 0 || (fp = fdopen(tfd, "w")) == NULL) { + umask(prev_umask); return; - - if ((fp = fdopen(tfd, "w")) == NULL) - return; - + } #else - char *filename; - - if ((filename = tempnam(NULL, APP_SHORTNAME)) == NULL) + // XXX tempnam is obsolete since POSIX.2008-1 + // tmpfile is not an option, we want the created files to stick around + if ((filename = tempnam(NULL, APP_SHORTNAME)) == NULL || + (fp = fopen(filename, "w")) == NULL) { + umask(prev_umask); return; - - if ((fp = fopen(filename, "w")) == NULL) - return; - + } #endif + umask(prev_umask); if (Config.EmailFrom) fprintf(fp, "From: %s\n", Config.EmailFrom); @@ -156,16 +155,15 @@ fprintf(fp, "From: %s@%s\n", APP_SHORTNAME, uniqueHostname()); fprintf(fp, "To: %s\n", Config.adminEmail); - fprintf(fp, "Subject: %s\n", dead_msg()); - fclose(fp); snprintf(command, 256, "%s %s < %s", Config.EmailProgram, Config.adminEmail, filename); - if (system(command)) {} /* XXX should avoid system(3) */ - unlink(filename); +#if !HAVE_MKSTEMP + xfree(filename); // tempnam() requires us to free its allocation +#endif } void