]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
13 years agoBug 3190: Large HTTP POST stuck after early ICAP 400 error response
Christos Tsantilas [Thu, 6 Oct 2011 08:29:03 +0000 (11:29 +0300)] 
Bug 3190: Large HTTP POST stuck after early ICAP 400 error response

When an ICAP REQMOD service responds with an error to
(or the REQMOD transaction aborts while processing) a large HTTP
request, the HTTP request may get stuck because the request body
buffer gets full and nobody consumes the no-longer-needed content.

The ICAP code quits but leaves the body buffer intact in case the
client-side code wants to bypass the error. After that, nobody consumes
the request body because the buggy client side does not inform the body
pipe that there will be no other consumers, which would have triggered
a noteBodyConsumerAborted() callback and enable auto-consumption or closed
the client connection.

This is a Measurement Factory project

13 years agoSourceFormat Enforcement
Automatic source maintenance [Wed, 5 Oct 2011 00:19:46 +0000 (18:19 -0600)] 
SourceFormat Enforcement

13 years agoRefactored HttpHdrCc, with improved MemPools integration and more efficient parsing.
Francesco Chemolli [Tue, 4 Oct 2011 21:27:42 +0000 (23:27 +0200)] 
Refactored HttpHdrCc, with improved MemPools integration and more efficient parsing.
Implemented StringArea class.

13 years agoMerged from trunk
Francesco Chemolli [Tue, 4 Oct 2011 11:52:17 +0000 (13:52 +0200)] 
Merged from trunk

13 years agoBug fix: a test was flipped during conversion.
Francesco Chemolli [Tue, 4 Oct 2011 10:34:19 +0000 (12:34 +0200)] 
Bug fix: a test was flipped during conversion.

13 years agoOptimization in HttpHdrCc::packInto : if there is nothing to fill in don't even look
Francesco Chemolli [Mon, 3 Oct 2011 15:44:56 +0000 (17:44 +0200)] 
Optimization in HttpHdrCc::packInto : if there is nothing to fill in don't even look

13 years agoCleanup: only copy error-details.txt once per language
Amos Jeffries [Mon, 3 Oct 2011 10:55:34 +0000 (04:55 -0600)] 
Cleanup: only copy error-details.txt once per language

13 years agoBug 3373: invalid URL in ERR_CACHE_ACCESS_DENIED
David Parks [Mon, 3 Oct 2011 10:41:22 +0000 (23:41 +1300)] 
Bug 3373: invalid URL in ERR_CACHE_ACCESS_DENIED

13 years agoBug 3346: forward.cc:364: "entry->store_status == STORE_PENDING"
Christos Tsantilas [Mon, 3 Oct 2011 10:17:42 +0000 (13:17 +0300)] 
Bug 3346: forward.cc:364: "entry->store_status == STORE_PENDING"

While the server writes the response to Store, the client side may
synchronously abort the entry. This happens, for example, when the
server receives a 304 response and handleIMSReply calls
sendClientOldEntry, which calls storeUnregister with our entry,
resulting in CheckQuickAbort.

Once server store write returns, if the server is done, it calls
FwdState::completed(). At that time, the server does not know that (and
should not care whether) the entry was aborted. Thus, we need to handle
aborted entries in FwdState::completed.

This is a Measurement Factory project.

13 years agoOptimized HttpHdrCc::packInto and clarified its behaviour in comments
Francesco Chemolli [Thu, 29 Sep 2011 06:53:34 +0000 (08:53 +0200)] 
Optimized HttpHdrCc::packInto and clarified its behaviour in comments
Negative values to Cache-Control directives are now explicitly discarded
Clarified documentation

13 years agoExplicitly check that integer-carrying Cache-control directives are positive.
Francesco Chemolli [Wed, 28 Sep 2011 22:42:19 +0000 (00:42 +0200)] 
Explicitly check that integer-carrying Cache-control directives are positive.
Rename MAX_STALE_ALWAYS to MAX_STALE_ANY and changed its representation to very large positive integer.
Implemented internal HttpHdrCc::setValue call.
Removed unnecessarily explicitly-masked StringArea default constructor.

13 years agoImplemented explicit getters/setters for all Cache-Control directives
Francesco Chemolli [Wed, 28 Sep 2011 12:13:22 +0000 (14:13 +0200)] 
Implemented explicit getters/setters for all Cache-Control directives
Moved httpHdrCcPackInto to an HttpHdrCc class member

13 years agoavoided temporary in HttpHdrCc name-to-id lookup
Francesco Chemolli [Tue, 27 Sep 2011 21:48:12 +0000 (23:48 +0200)] 
avoided temporary in HttpHdrCc name-to-id lookup
Started implementing have/set/get/clear combo for all members of HttpHdrCc
Fixed zero-pointer-dereference in http.cc

13 years agoMade HttpHdrCc::mask private.
Francesco Chemolli [Tue, 27 Sep 2011 11:16:01 +0000 (13:16 +0200)] 
Made HttpHdrCc::mask private.

13 years agoImplemented HttpHdrCc::set and isSet to manipulate the mask
Francesco Chemolli [Tue, 27 Sep 2011 10:40:29 +0000 (12:40 +0200)] 
Implemented HttpHdrCc::set and isSet to manipulate the mask

13 years agoImproved HttpHdrCc documentation
Francesco Chemolli [Tue, 27 Sep 2011 06:14:57 +0000 (08:14 +0200)] 
Improved HttpHdrCc documentation
Reverted spurious change in Makefile.am
Fixed potential null pointer dereference in refresh.cc
Reverted unnecessary changes to HttpHeader::getCc
Removed explicit constructor requirement for HttpHdrCc

13 years agoFixed consistency typo in HttpHdrCc.
Francesco Chemolli [Tue, 27 Sep 2011 05:31:10 +0000 (07:31 +0200)] 
Fixed consistency typo in HttpHdrCc.

13 years agoImplemented base/StringArea
Francesco Chemolli [Tue, 27 Sep 2011 05:16:58 +0000 (07:16 +0200)] 
Implemented base/StringArea

13 years agoFixed Makefile.
Francesco Chemolli [Mon, 26 Sep 2011 21:31:34 +0000 (23:31 +0200)] 
Fixed Makefile.

13 years agoClarified some auxiliary struct documentation
Francesco Chemolli [Mon, 26 Sep 2011 20:05:40 +0000 (22:05 +0200)] 
Clarified some auxiliary struct documentation

13 years agoInlined getters/setters
Francesco Chemolli [Mon, 26 Sep 2011 19:58:43 +0000 (21:58 +0200)] 
Inlined getters/setters

13 years agoMade some "unset" checks explicit.
Francesco Chemolli [Mon, 26 Sep 2011 19:50:51 +0000 (21:50 +0200)] 
Made some "unset" checks explicit.

13 years ago(no commit message)
Francesco Chemolli [Mon, 26 Sep 2011 06:20:09 +0000 (08:20 +0200)] 

13 years agoCreated getters and setters for HttpHdrCc::min_fresh
Francesco Chemolli [Sun, 25 Sep 2011 13:06:40 +0000 (15:06 +0200)] 
Created getters and setters for HttpHdrCc::min_fresh

13 years agoAuthor: Andrew Beverley <andy@andybev.com>
Henrik Nordstrom [Sun, 25 Sep 2011 01:36:21 +0000 (03:36 +0200)] 
Author: Andrew Beverley <andy@andybev.com>

This patch stops an SSL header file being included when SSL
support has not been requested.

13 years agoSourceFormat Enforcement
Automatic source maintenance [Sat, 24 Sep 2011 00:13:48 +0000 (18:13 -0600)] 
SourceFormat Enforcement

13 years agoImplemented getters/setters for HttpHdrCc::stale_if_error
Francesco Chemolli [Fri, 23 Sep 2011 08:36:42 +0000 (10:36 +0200)] 
Implemented getters/setters for HttpHdrCc::stale_if_error
Fixed formatting in HttpHdrCc.c

13 years agoWorkaround: disable translation of error-details.txt
Amos Jeffries [Fri, 23 Sep 2011 00:29:41 +0000 (18:29 -0600)] 
Workaround: disable translation of error-details.txt

po2txt was translating sub-strings inside name: fields.

This is a TEMPORARY measure to prevent breakign any more installations.

13 years agoFixed SwapDir::reconfigure() arguments broken by my poor conflict resolution.
Alex Rousskov [Thu, 22 Sep 2011 22:02:39 +0000 (16:02 -0600)] 
Fixed SwapDir::reconfigure() arguments broken by my poor conflict resolution.

13 years agoFix cache_dir type check during reconfiguration.
Dmitry Kurochkin [Thu, 22 Sep 2011 21:47:32 +0000 (15:47 -0600)] 
Fix cache_dir type check during reconfiguration.

SwapDir::type() returns C strings which should be compared with
strcmp(3) instead of checking pointers for equality.

13 years agoRemove SwapDir::reconfigure() arguments since they are not used.
Dmitry Kurochkin [Thu, 22 Sep 2011 21:42:46 +0000 (15:42 -0600)] 
Remove SwapDir::reconfigure() arguments since they are not used.

Before the change, SwapDir::reconfigure() took index and path
arguments, but none of them was actually used: neither index nor path
can be changed during reconfigure.  And both index and path are
available as SwapDir members so there is no reason to have these
arguments.

13 years agoIgnore and warn about attempts to reconfigure static Rock store options.
Dmitry Kurochkin [Thu, 22 Sep 2011 21:36:59 +0000 (15:36 -0600)] 
Ignore and warn about attempts to reconfigure static Rock store options.

Some Rock store options cannot be changed dynamically: path, size, and
max-size.  Before the change, there were no checks during reconfigure
to prevent changing these options.  This may lead to Rock cache
corruption and other bugs.  The patch adds necessary checks to Rock
store code.  If user tries to change an option that cannot be updated
dynamically, a warning is reported and the value is left unchanged.

13 years agoBug fix: "(ssl_crtd): Cannot add certificate to db" when updating expired cert
Christos Tsantilas [Thu, 22 Sep 2011 16:37:55 +0000 (19:37 +0300)] 
Bug fix: "(ssl_crtd): Cannot add certificate to db" when updating expired cert

When ssl_crtd helper needs to add a fresh certificate to the database but
finds an expired certificate already stored, ssl_crtd deletes the expired
certificate file from disk before adding the fresh one. However, the addition
still fails because the expired certificate was not removed from database
indexes.

This fix:
  - Adds code to update database indexes upon deletion of a row.
  - Polishes certificates deletion code to avoid duplication.

TODO: Report failure details to Squid and make certificate-specific failures
not fatal for the ssl_crtd helper.

This is a Measurement Factory project.

13 years agoBug 3351: FTP timeout causing "store_status == STORE_PENDING" assertion
Alex Rousskov [Thu, 22 Sep 2011 15:23:11 +0000 (09:23 -0600)] 
Bug 3351: FTP timeout causing "store_status == STORE_PENDING" assertion

If the entry was aborted while we were timing out, do not attempt to
write the timeout error message to it.

TODO: Other FTP code should call abortOnBadEntry() instead of testing for
ENTRY_ABORTED and calling abortTransaction().

13 years agoimplemented getters and setters for HttpHdrCc::max_stale
Francesco Chemolli [Thu, 22 Sep 2011 13:59:53 +0000 (15:59 +0200)] 
implemented getters and setters for HttpHdrCc::max_stale

13 years agoRenamed include guard for HttpHdrCc
Francesco Chemolli [Thu, 22 Sep 2011 13:45:49 +0000 (15:45 +0200)] 
Renamed include guard for HttpHdrCc

13 years agoSTUB: wordlist
Amos Jeffries [Thu, 22 Sep 2011 02:14:15 +0000 (14:14 +1200)] 
STUB: wordlist

13 years agoBug 3355: configure setting --with-swapdir ignored by netdb
Peter Pramberger [Thu, 22 Sep 2011 00:46:26 +0000 (18:46 -0600)] 
Bug 3355: configure setting --with-swapdir ignored by netdb

13 years agoSourceFormat Enforcement
Automatic source maintenance [Thu, 22 Sep 2011 00:15:50 +0000 (18:15 -0600)] 
SourceFormat Enforcement

13 years agoTemporary fix: Avoid killing Coordinator with unregistered cache mgr actions
Alex Rousskov [Wed, 21 Sep 2011 18:05:55 +0000 (12:05 -0600)] 
Temporary fix: Avoid killing Coordinator with unregistered cache mgr actions
that cause isOpen() assertions.

If a worker forwards a cache manager request to Coordinator and Coordinator
does not have that action registered, CacheManager::createRequestedAction()
throws (as it should) and Mgr::Request cleanup asserts when its half-baked
connection tries to close a not-yet-imported socket descriptor.

This workaround catches the exception, reports it, and manually closes the
socket descriptor. It also prevents an ACK response from being sent to the
worker, which triggers a worker timeout.

Mid-term TODO: Coordinator should register all actions that are known to kids.
Should Coordinator respond with an error instead of relying on a timeout?

Long-term TODO: Consider an API where cache manager responses can be
aggregated and formatted by Coordinator without knowing action-specific
details. After all, there are not so many types of action information (size,
count, rate, etc.) and most actions have simple reporting formats. Currently,
it is awkward to guarantee that Coordinator and all workers know all actions,
especially when some actions may be specific to non-worker kids such as
Coordinator and diskers.

13 years agoImplemented HttpHdrCc::s_maxage getters and setters and value-based "unset" state.
Francesco Chemolli [Wed, 21 Sep 2011 07:52:42 +0000 (09:52 +0200)] 
Implemented HttpHdrCc::s_maxage getters and setters and value-based "unset" state.

13 years agoImplemented HttpHdrCc::MAX_AGE_UNSET constant and used it instead of mask
Francesco Chemolli [Wed, 21 Sep 2011 07:32:21 +0000 (09:32 +0200)] 
Implemented HttpHdrCc::MAX_AGE_UNSET constant and used it instead of mask

13 years agoext_session_acl: version 1.1
Andrew Beverley [Wed, 21 Sep 2011 00:19:19 +0000 (12:19 +1200)] 
ext_session_acl: version 1.1

 * Add fixed period session support with -T

 * Fix synchronization between multiple helpers accessing the database

 * Fix crash when configured with non-concurrent settings.

13 years agoMerged from trunk
Francesco Chemolli [Tue, 20 Sep 2011 21:35:59 +0000 (23:35 +0200)] 
Merged from trunk

13 years agoImplemented full setter/getter structure for HttpHdrCc::max_age refactoring.
Francesco Chemolli [Tue, 20 Sep 2011 21:35:03 +0000 (23:35 +0200)] 
Implemented full setter/getter structure for HttpHdrCc::max_age refactoring.

13 years agoCleanup: Drop useless ; and whitespaces
Amos Jeffries [Sun, 18 Sep 2011 02:54:18 +0000 (14:54 +1200)] 
Cleanup: Drop useless ; and whitespaces

13 years agoEnumerate all ACL results for always_direct/never_direct.
Amos Jeffries [Sun, 18 Sep 2011 00:54:22 +0000 (12:54 +1200)] 
Enumerate all ACL results for always_direct/never_direct.

Some ACLs (ie random) produce DUNNO state. This avoids incorrect messages
now and on future states.

13 years agoFix typo in IPF interception
Amos Jeffries [Sun, 18 Sep 2011 00:37:53 +0000 (12:37 +1200)] 
Fix typo in IPF interception

13 years agoRemoved assert with a "pointless comparison" to make ICC compiler happier.
Alex Rousskov [Sat, 17 Sep 2011 16:46:43 +0000 (10:46 -0600)] 
Removed assert with a "pointless comparison" to make ICC compiler happier.

13 years agoMerged from trunk
Francesco Chemolli [Fri, 16 Sep 2011 18:33:19 +0000 (20:33 +0200)] 
Merged from trunk

13 years agoPrep for 3.2.0.12
Amos Jeffries [Fri, 16 Sep 2011 11:29:10 +0000 (05:29 -0600)] 
Prep for 3.2.0.12

13 years agoRemoved assert with a "pointless comparison" to make ICC compiler happier.
Alex Rousskov [Fri, 16 Sep 2011 04:36:49 +0000 (22:36 -0600)] 
Removed assert with a "pointless comparison" to make ICC compiler happier.

13 years agoDo not let cache manager requests kill SMP Squid using isOpen() assertion.
Alex Rousskov [Thu, 15 Sep 2011 18:16:59 +0000 (12:16 -0600)] 
Do not let cache manager requests kill SMP Squid using isOpen() assertion.

As the comment above the close call implies, we have not imported the foreign
socket descriptor into our fd_table yet. We must use raw close(2), just like
the corresponding Mgr::Request::Request(msg) code that allocates request.conn,
uses raw assignment to give that half-baked connection a descriptor.

TODO: This direct manipulation of Connection::fd is ugly, and this half-baked
connection will most likely cause more [hidden] problems down the road. For
example, Mgr::Request destructor will assert in a similar way if the request
object is destroyed before Action::respond() is called.

13 years agoRemoved "pointless comparison of unsigned integer with 0" to make ICC happier.
Alex Rousskov [Thu, 15 Sep 2011 14:54:06 +0000 (08:54 -0600)] 
Removed "pointless comparison of unsigned integer with 0" to make ICC happier.

Besides making ICC compiler happier, we should not check parameter values that
are just passed to other Squid code. Let the recepient code check them.

13 years agoMaintenance: snapshot needs to cope with out-of-tree builds
Automatic source maintenance [Thu, 15 Sep 2011 14:07:43 +0000 (08:07 -0600)] 
Maintenance: snapshot needs to cope with out-of-tree builds

13 years agoCheck for and use __sync_sub_and_fetch() and such for atomic decrement.
Alex Rousskov [Thu, 15 Sep 2011 03:44:50 +0000 (21:44 -0600)] 
Check for and use __sync_sub_and_fetch() and such for atomic decrement.

This is possibly more efficient or perhaps even the only correct way to
decrement atomically. It also helps ICC compiler happier. Somehow, I missed
that __sync_fetch_and_sub() and such exist!

13 years agoSourceFormat Enforcement
Automatic source maintenance [Thu, 15 Sep 2011 00:12:28 +0000 (18:12 -0600)] 
SourceFormat Enforcement

13 years agoMade Ipc::StoreMap::Shared public to make ICC compiler happier.
Alex Rousskov [Wed, 14 Sep 2011 20:07:28 +0000 (14:07 -0600)] 
Made Ipc::StoreMap::Shared public to make ICC compiler happier.

Ipc::StoreMap class kids need access to Shared::SharedMemorySize (at least) so
the Shared type declaration should be at least protected. Made it public
because the currently public Ipc::StoreMap::Owner typedef uses it.

13 years agoFixed negative time value detection and removed "pointless comparison with 0"
Alex Rousskov [Wed, 14 Sep 2011 19:59:30 +0000 (13:59 -0600)] 
Fixed negative time value detection and removed "pointless comparison with 0"
to make ICC compiler happier.

13 years agoMore revision-oriented fixes.
Francesco Chemolli [Wed, 14 Sep 2011 18:25:10 +0000 (20:25 +0200)] 
More revision-oriented fixes.

13 years agoIntroduced experimental strblob class to more efficiently handle Cache-Control header...
Francesco Chemolli [Wed, 14 Sep 2011 18:21:46 +0000 (20:21 +0200)] 
Introduced experimental strblob class to more efficiently handle Cache-Control header lookups
Various performance improvements.
Renamed HttpHdrCc::parseInit() to parse()
Reverted some changes in HTtpHdrCc::parse() to facilitate review.
Removed useless HttpHdrCc::setSMaxAge
Removed Author attribution - too many authors to single any one out
Removed parametric HttpHdrCc constructor, made parametric.
Removed duplicate mempool definition

13 years agoImplemented the second Store::get() API to make ICC compiler happier.
Alex Rousskov [Wed, 14 Sep 2011 16:34:40 +0000 (10:34 -0600)] 
Implemented the second Store::get() API to make ICC compiler happier.

TODO: Remove this second Store::get() member as unused, undocumented, and
inefficient?

13 years agoMoved "meaningless" const to make ICC compiler happier.
Alex Rousskov [Wed, 14 Sep 2011 16:31:00 +0000 (10:31 -0600)] 
Moved "meaningless" const to make ICC compiler happier.

TODO: The Ipc::Mem::Pointer API looks inconsistent w.r.t. const use.

13 years agoSourceFormat Enforcement
Automatic source maintenance [Wed, 14 Sep 2011 00:12:35 +0000 (18:12 -0600)] 
SourceFormat Enforcement

13 years agoSMP Caching: Core changes, IPC primitives, Shared memory cache, and Rock Store
Alex Rousskov [Tue, 13 Sep 2011 16:47:32 +0000 (10:47 -0600)] 
SMP Caching: Core changes, IPC primitives, Shared memory cache, and Rock Store

Core changes
------------

* Added MemObject::expectedReplySize() and used it instead of object_sz.

When deciding whether an object with a known content length can be
swapped out, do not wait until the object is completely received and its
size (mem_obj->object_sz) becomes known (while asking the store to
recheck in vain with every incoming chunk). Instead, use the known
content length, if any, to make the decision.

This optimizes the common case where the complete object is eventually
received and swapped out, preventing accumulating potentially large
objects in RAM while waiting for the end of the response. Should not
affect objects with unknown content length.

Side-effect1: probably fixes several cases of unknowingly using negative
(unknown) mem_obj->object_sz in calculations. I added a few assertions
to double check some of the remaining object_sz/objectLen() uses.

Side-effect2: When expectedReplySize() is stored on disk as StoreEntry
metadata, it may help to detect truncated entries when the writer
process dies before completing the swapout.

* Removed mem->swapout.memnode in favor of mem->swapout.queue_offset.

The code used swapout.memnode pointer to keep track of the last page
that was swapped out. The code was semi-buggy because it could reset the
pointer to NULL if no new data came in before the call to doPages().
Perhaps the code relied on the assumption that the caller will never
doPages if there is no new data, but I am not sure that assumption was
correct in all cases (it could be that I broke the calling code, of course).

Moreover, the page pointer was kept without any protection from page
disappearing during asynchronous swapout. There were "Evil hack time"
comments discussing how the page might disappear.

Fortunately, we already have mem->swapout.queue_offset that can be fed
to getBlockContainingLocation to find the page that needs to be swapped
out. There is no need to keep the page pointer around. The
queue_offset-based math is the same so we are not adding any overheads
by using that offset (in fact, we are removing some minor computations).

* Added "close how?" parameter to storeClose() and friends.

The old code would follow the same path when closing swapout activity
for an aborted entry and when completing a perfectly healthy swapout. In
non-shared case, that could have been OK because the abort code would
then release the entry, removing any half-written entry from the index
and the disk (but I am not sure that release happened fast enough in
100% of cases).

When the index and disk storage is shared among workers, such
"temporary" inconsistencies result in truncated responses being
delivered by other workers to the user because once the swapout activity
is closed, other workers can start using the entry.

By adding the "close how?" parameter to closing methods we allow the
core and SwapDir-specific code to handle aborted swapouts appropriately.

Since swapin code is "read only", we do not currently distinguish
between aborted and fully satisfied readers: The readerGone enum value
applies to both cases. If needed, the SwapDir reading code can make that
distinction by analyzing how much was actually swapped in.

* Moved "can you store this entry?" code to virtual SwapDir::canStore().

The old code had some of the tests in SwapDir-specific canStore()
methods and some in storeDirSelect*() methods. This resulted in
inconsistencies, code duplication, and extra calculation overheads.
Making this call virtual allows individual cache_dir types to do custom
access controls.

The same method is used for cache_dir load reporting (if it returns
true). Load management needs more work, but the current code is no worse
than the old one in this aspect, and further improvements are outside
this change scope.

* Minimized from-disk StoreEntry loading/unpacking code duplication.

Moved common (and often rather complex!) code from store modules into
storeRebuildLoadEntry, storeRebuildParseEntry, and storeRebuildKeepEntry.

* Do not set object_sz when the entry is aborted because the true object
size (HTTP reply headers + body) is not known in this case. Setting
object_sz may fool client-side code into believing that the object is
complete.

This addresses an old RBC's complaint.

* When swapout initiation fails, mark swapout decision as
MemObject::SwapOut::swImpossible. This prevents the caller code from trying to
swap out again and again because swap_status becomes SWAPOUT_NONE.

TODO: Consider add SWAPOUT_ERROR, STORE_ERROR, and similar states. It
may solve several problems where the code sees _NONE or _OK and thinks
everything is peachy when in fact there was an error.

* Call haveParsedReplyHeaders() before entry->replaceHttpReply().

HaveParsedReplyHeaders() sets the entry public key and various flags (at
least). ReplaceHttpReply() packs reply headers, starting swapout process.
It feels natural to adjust the entry _before_ we pack/swap it, but I may be
missing some side-effects here.

The change was necessary because we started calling checkCachable() from
swapoutPossible(). If haveParsedReplyHeaders() is not called before we swap
out checks, the entry will still have the private key and will be declared
impossible to cache.

* Extracted the write-to-store step from StoreEntry::replaceHttpReply().

This allows the caller to set the reply for the entry and then update the
entry and the reply before writing them to store. For example, the server-side
haveParsedReplyHeaders() code needs to set the entry timestamps and make the
entry key public before the entry starts swapping out, but the same code also
needs access to entry->getReply() and such for timestampsSet() and similar
code to work correctly.

TODO: Calls to StoreEntry::replaceHttpReply() do not have to be modified
because replaceHttpReply() does write by default. However, it is likely that
callers other than ServerStateData::setFinalReply() should take advantage of
the new split interface because they call timestampsSet() and such after
replaceHttpReply().

* Moved SwapDir::cur_size and n_disk_objects to specific SwapDirs. Removed
updateSize().  Some cache_dirs maintain their own maps and size statistics,
making the one-size-fits-all SwapDir members inappropriate.

* A new SwapDir public method swappedOut() added. It is called from
storeSwapOutFileClosed() to notify SwapDir that an object was swapped
out.

* Change SwapDir::max_size to bytes, make it protected, use maxSize() instead.

Change SwapDir::cur_size to bytes, make it private, use currentSize() instead.

Store Config.Store.avgObjectSize in bytes to avoid repeated and error-prone
KB<->bytes conversions.

* Change Config.cacheSwap.swapDirs and StoreEntry::store() type to SwapDir.

This allows using SwapDir API without dynamic_cast.

* Always call StoreEntry::abort() instead of setting ENTRY_ABORTED manually.

* Rely on entry->abort() side-effects if ENTRY_ABORTED was set.

* Added or updated comments to better document current code.

* Added operator << for dumping StoreEntry summary into the debugging
log. Needs more work to report more info (and not report yet-unknown info).

* Fixed blocking reads that were sometimes reading from random file offsets.

Core "disk file" reading code assumed that if the globally stored disk.offset
matches the desired offset, there is no reason to seek. This was probably done
to reduce seek overhead between consecutive reads. Unfortunately, the disk
writing code did not know about that optimization and left F->disk.offset
unchanged after writing.

This may have worked OK for UFS if it never writes to the file it reads from,
but it does not work for store modules that do both kinds of I/O at different
offsets of the same disk file.

Eventually, implement this optimization correctly or remove disk.offset.

IPC primitives
--------------

To make SMP disk and memory caching non-blocking and correct, worker and
disker processes must asynchronously communicate with each other. We are
adding a collection of classes that support such communication.

At the base of the collection is the AtomicWordT template that uses GCC atomic
primitives such as __sync_add_and_fetch() to perform atomic operations on
integral values in memory shared by multiple Squid kids. AtomicWordT is used
to implement non-blocking shared locks, queues, store tables, and page pools.

To avoid blocking or very long searches, many operations are "optimistic" in
nature. For example, it is possible that an atomic store map will refuse to
allocate an entry for two processes even though a blocking implementation
would have allowed one of the processes to get the map slot. We speculate that
such conflict resolution is better than blocking locks when it comes to
caching, especially if the conflicts are rare due to large number of cache
entries, fast operations, and relatively small number of kids.

TODO: Eventually, consider breaking locks left by dead kids.

Shared Memory Cache
-------------------

* Added initial shared memory cache implementation (MemStore).

The shared memory cache keeps its own compact index of cached entries using
extended Ipc::StoreMap class (MemStoreMap). The cache also strives to keep its
Root.get() results out of the store_table except during transit.

Eventually, the non-shared/local memory cache should also be implemented
using a MemStore-like class, I think. This will allow to clearly isolate
local from shared memory cache code.

Allow the user to explicitly disable shared memory caching in SMP mode via
memory_cache_shared to squid.conf. Report whether mem_cache is shared.

Disable shared memory caching by default if atomic operations are not
supported. Prohibit shared memory caching if atomic operations are not
supported.

TODO: Better limits/separation for cache and I/O shared memory pages.
Eventually, support shared memory caching of multi-page entries.

Rock Store
----------

Rock Store uses a single [large] database-style file per cache_dir to store
cached responses and metadata. This part of the design is similar to COSS.
Rock Store does not maintain or rely on swap.state "log" for recovery.
Instead, the database is scanned in the background to load entries when Squid
starts. Rock Store maintains its own index of cached entries and avoids global
store_table. All entries must be max-size or smaller.

In SMP mode, each Rock cache_dir is given a dedicated Kid processes called
"disker". All SMP workers communicate with diskers to store misses and load
hits, using shared memory pages and atomic shared memory queues. Disker blocks
when doing disk I/O but workers do not. Any Diskers:Workers ratio is supported
so that the user can find and configure the optimal number of workers and
diskers for a given number of disks and CPU cores.

In non-SMP mode, should use good old blocking disk I/O, without any diskers,
but this has not been tested recently and probably needs more work.

Feature page: http://wiki.squid-cache.org/Features/RockStore

TODO: Disk rate limit to protect Squid from disk overload. More stats.
Multiple readers? Seek optimization? Remove known max-size requirement?

13 years agoMerged from trunk
Francesco Chemolli [Mon, 12 Sep 2011 23:25:55 +0000 (01:25 +0200)] 
Merged from trunk

13 years agoAdded some documentation
Francesco Chemolli [Mon, 12 Sep 2011 23:24:54 +0000 (01:24 +0200)] 
Added some documentation

13 years agoImplement String::operator<
Francesco Chemolli [Mon, 12 Sep 2011 23:21:15 +0000 (01:21 +0200)] 
Implement String::operator<

13 years agoRenamed work-files to their original names.
Francesco Chemolli [Mon, 12 Sep 2011 22:54:38 +0000 (00:54 +0200)] 
Renamed work-files to their original names.
Added some documentation.
Implemented HttpHdrCc::clear()

13 years agoRemoved unused httpHdrCcDup function.
Francesco Chemolli [Mon, 12 Sep 2011 19:20:37 +0000 (21:20 +0200)] 
Removed unused httpHdrCcDup function.

13 years agoC++-refactored httpHdrCcSetMaxAge and httpHdrCcSetSMaxAge
Francesco Chemolli [Mon, 12 Sep 2011 19:05:57 +0000 (21:05 +0200)] 
C++-refactored httpHdrCcSetMaxAge and httpHdrCcSetSMaxAge

13 years agoC++-refactored HttpHdrCcDestroy. Object can now be safely deleted.
Francesco Chemolli [Mon, 12 Sep 2011 17:45:26 +0000 (19:45 +0200)] 
C++-refactored HttpHdrCcDestroy. Object can now be safely deleted.

13 years agoRemoved httpHdrCcParseCreate as a first-class method, it only had one in-class caller.
Francesco Chemolli [Mon, 12 Sep 2011 16:07:03 +0000 (18:07 +0200)] 
Removed httpHdrCcParseCreate as a first-class method, it only had one in-class caller.
HttpHdrCc::parseInit now takes a const String reference argument.

Same function of httpHdrCcParseCreate can be obtained by new HttpHdrCc() + HttpHdrCc::parseInit()

13 years agoHttpHdrCc refactoring: c++-ify parseInit method.
Francesco Chemolli [Mon, 12 Sep 2011 13:50:10 +0000 (15:50 +0200)] 
HttpHdrCc refactoring: c++-ify parseInit method.

13 years agoCache-Control headers refactoring: c++-ize constuctors
Francesco Chemolli [Mon, 12 Sep 2011 12:02:55 +0000 (14:02 +0200)] 
Cache-Control headers refactoring: c++-ize constuctors

13 years agoMerged from parent (trunk r11728, v3.2.0.11+).
Alex Rousskov [Mon, 12 Sep 2011 00:31:13 +0000 (18:31 -0600)] 
Merged from parent (trunk r11728, v3.2.0.11+).

13 years agoUse STUB_RETVAL() to minimize the number of stub lines.
Alex Rousskov [Mon, 12 Sep 2011 00:29:56 +0000 (18:29 -0600)] 
Use STUB_RETVAL() to minimize the number of stub lines.

13 years agoSourceFormat Enforcement
Automatic source maintenance [Mon, 12 Sep 2011 00:12:21 +0000 (18:12 -0600)] 
SourceFormat Enforcement

13 years agoPolished comments related to sizing, resizing, and space wasting.
Alex Rousskov [Mon, 12 Sep 2011 00:07:25 +0000 (18:07 -0600)] 
Polished comments related to sizing, resizing, and space wasting.

Related code needs more work.

13 years agoRemoved tests/testRock placeholder until we have test cases.
Alex Rousskov [Sun, 11 Sep 2011 23:40:46 +0000 (17:40 -0600)] 
Removed tests/testRock placeholder until we have test cases.

13 years agoFixed n_strands comment to use the right doxygen syntax.
Alex Rousskov [Sun, 11 Sep 2011 22:21:35 +0000 (16:21 -0600)] 
Fixed n_strands comment to use the right doxygen syntax.

13 years agoPolished debugging: Use DBG_CRITICAL for level-0 messages.
Alex Rousskov [Sun, 11 Sep 2011 22:08:15 +0000 (16:08 -0600)] 
Polished debugging: Use DBG_CRITICAL for level-0 messages.

13 years agoPolished cache_mem description by adding some shared memory cache specifics.
Alex Rousskov [Sun, 11 Sep 2011 22:02:56 +0000 (16:02 -0600)] 
Polished cache_mem description by adding some shared memory cache specifics.

13 years agoRemoved explicit sys/types.h #inclusion per Amos request.
Alex Rousskov [Sun, 11 Sep 2011 21:52:19 +0000 (15:52 -0600)] 
Removed explicit sys/types.h #inclusion per Amos request.

13 years agoNamed StoreEntry::swap_filen maximum value to avoid magic constants.
Alex Rousskov [Sun, 11 Sep 2011 21:44:54 +0000 (15:44 -0600)] 
Named StoreEntry::swap_filen maximum value to avoid magic constants.

13 years agoCleanup: DIRECT access decision debugging and process
Amos Jeffries [Sun, 11 Sep 2011 11:25:50 +0000 (23:25 +1200)] 
Cleanup: DIRECT access decision debugging and process

* add debug messages to trace the reason for DIRECT

* initialize ps_state with correct defaults for always/never/direct

* handle extended ACL results outputs (warn and ignore result)

13 years agoDocs: clarify retry_on_error situations
Amos Jeffries [Sun, 11 Sep 2011 10:22:14 +0000 (04:22 -0600)] 
Docs: clarify retry_on_error situations

13 years agoDocs: mention Host validation effect on url_rewrite_host_header
Amos Jeffries [Sun, 11 Sep 2011 05:22:43 +0000 (17:22 +1200)] 
Docs: mention Host validation effect on url_rewrite_host_header

13 years agoPolished debugging, #includes. And mkdir() no longer needs _SQUID_MSWIN_.
Alex Rousskov [Sat, 10 Sep 2011 19:38:15 +0000 (13:38 -0600)] 
Polished debugging, #includes. And mkdir() no longer needs _SQUID_MSWIN_.

13 years agoRenamed RockFile.h to RockDbCell.h to better match content. Polished docs.
Alex Rousskov [Sat, 10 Sep 2011 16:38:36 +0000 (10:38 -0600)] 
Renamed RockFile.h to RockDbCell.h to better match content. Polished docs.

13 years agoUse "#if HAVE_" and not "#ifdef HAVE_" per Squid style guidelines.
Alex Rousskov [Sat, 10 Sep 2011 04:27:57 +0000 (22:27 -0600)] 
Use "#if HAVE_" and not "#ifdef HAVE_" per Squid style guidelines.

13 years agoReversed r11339: Rock Store no longer needs time_msec parsing functions.
Alex Rousskov [Sat, 10 Sep 2011 04:22:16 +0000 (22:22 -0600)] 
Reversed r11339: Rock Store no longer needs time_msec parsing functions.

Until they are reshaped to be available for name=time_msec options parsing,
that is.

13 years agoFTP: use random outgoing port on PASV connections
Amos Jeffries [Sat, 10 Sep 2011 03:57:08 +0000 (21:57 -0600)] 
FTP: use random outgoing port on PASV connections

13 years agoMoved squid.conf global disk_io_timeout to cache_dir-local swap-timeout.
Alex Rousskov [Sat, 10 Sep 2011 01:25:27 +0000 (19:25 -0600)] 
Moved squid.conf global disk_io_timeout to cache_dir-local swap-timeout.

The I/O timeout option belongs to cache_dir because not all cache_dir types
support it and because different cache_dirs may need different timeout values,
especially if some of them handle very large or otherwise unusual files.

To propagate the knowledge of the option down to DiskIO/IpcIoFile I decided
to add a DiskFile::Config class and DiskFile::configure() method. At first
glance that API does not belong to DiskFile because only IpcIoFile supports
it. However, DiskFile may be a better location for it because

  * Other specific DiskIO files may want to support the same configuration
    API.

  * Placing API in IpcIoFile would require either making Rock Store dependent
    on IpcIoFile (in terms of linking and in terms of availability) or more
    complex API with multiple inheritance, dynamic casting and such. We can
    introduce the "more complex API" mentioned above later if needed.

Renamed "disk_io" to "swap" timeout because the option is about the whole swap
out/in delay (something an admin may care about) and not individual I/O
(something only low-level code should know about).

13 years agoSourceFormat Enforcement
Automatic source maintenance [Sat, 10 Sep 2011 00:12:21 +0000 (18:12 -0600)] 
SourceFormat Enforcement

13 years ago%la for intercepted connections
Christos Tsantilas [Fri, 9 Sep 2011 20:41:40 +0000 (23:41 +0300)] 
%la for intercepted connections

This patch adjusts the %la logformat code handling for intercepted connections
based on the following rules:
 - If the corresponding http_port or https_port option has an explicit
   listening host name or IP address, then log the IP address.
 - Otherwise, log a dash character.

Also adjusts %lp logformat code handling for intercepted connections to always
log the port number from the corresponding http_port or https_port option.

Amos comments about %la formating code:
For the record these are the permutations we seek to cover...

Scenario 1: client 192.168.0.3 connects to google (74.125.237.81). Gets intercepted into Squid.

  1a) squid.conf:  http_port 3129 intercept|tproxy

   tcpClient->remote == 192.168.0.3:$random    (%>a:%>p)
   tcpClient->local == 74.125.237.81:80        (%>la:%>lp)
   al->cache.port->s.local == 0.0.0.0:3129     (%la:%lp) [log "-"]

  1b) squid.conf:  http_port 192.168.0.1:3129 intercept|tproxy

   tcpClient->remote == 192.168.0.3:$random    (%>a:%>p)
   tcpClient->local == 74.125.237.81:80        (%>la:%>lp)
   al->cache.port->s.local == 192.168.0.1:3129  (%la:%lp) [log 192...]

Scenario 2: client 192.168.0.3 connects to Squid asking for http://google.com

  2a) squid.conf:  http_port 3128 [accel]

   tcpClient->remote == 192.168.0.3:$random    (%>a:%>p)
   tcpClient->local == 192.168.0.1:3128        (%>la:%>lp)
   al->cache.port->s.local == 0.0.0.0:3128     (%la:%lp) [log 192...]

  2b) squid.conf:  http_port 192.168.0.1:3128 [accel]

   tcpClient->remote == 192.168.0.3:$random    (%>a:%>p)
   tcpClient->local == 192.168.0.1:3128        (%>la:%>lp)
   al->cache.port->s.local == 192.168.0.1:3128 (%la:%lp) [log 192...]

Senario 3: squid generates an internal request.

 tcpClient == NULL    (%>a:%>p,%>la:%>lp) [log "-"]
 al->cache.port == NULL     (%la:%lp) [log "-"]

13 years agoProvided more documentation for memory_cache_shared, including DEFAULT_DOC.
Alex Rousskov [Fri, 9 Sep 2011 17:42:35 +0000 (11:42 -0600)] 
Provided more documentation for memory_cache_shared, including DEFAULT_DOC.

13 years agoPolished free_YesNoNone() to avoid creating a static function [call].
Alex Rousskov [Fri, 9 Sep 2011 16:57:10 +0000 (10:57 -0600)] 
Polished free_YesNoNone() to avoid creating a static function [call].

A good compiler can optimize free_YesNoNone() and its call away.

13 years agoFixed max-stale check. Entities not exceeding max-stale were marked as stale.
Alex Rousskov [Fri, 9 Sep 2011 16:33:54 +0000 (10:33 -0600)] 
Fixed max-stale check. Entities not exceeding max-stale were marked as stale.

Since the fixed check is performed for entities already suspected of being
stale by refreshCheck(), it is difficult to describe exactly which entities
were affected by the bug. A rough description would be "entities which would
otherwise qualify for a FRESH_OVERRIDE_EXPIRES or FRESH_OVERRIDE_LASTMOD
exceptions located below the fixed check.

Other concerns about staleness checks have been discussed on squid-dev's
"max_stale broken?" email thread.

13 years agoAdded RunnersRegistry, an API to register and, later, run a group of actions.
Alex Rousskov [Fri, 9 Sep 2011 16:16:43 +0000 (10:16 -0600)] 
Added RunnersRegistry, an API to register and, later, run a group of actions.

Useful for keeping general initialization/cleanup management code (e.g.,
main.cc) independent from specific initialization/cleanup code (e.g.,
Store file systems or memory cache) during staged initialization and
cleaning.

Designed with Rock Store needs in mind. Currently unused. Should eventually be
used for most modules initialization and cleanup, removing main.cc dependency
on those modules and perfecting [de]initialization order.