]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
14 years agoCode polishing: move Rock store entry limit calculation to entryLimitAllowed().
Dmitry Kurochkin [Wed, 27 Apr 2011 02:29:22 +0000 (06:29 +0400)] 
Code polishing: move Rock store entry limit calculation to entryLimitAllowed().

14 years agoInitialize and cleanup Rock shared maps using RunnersRegistry API.
Dmitry Kurochkin [Wed, 27 Apr 2011 01:52:46 +0000 (05:52 +0400)] 
Initialize and cleanup Rock shared maps using RunnersRegistry API.

14 years agoRework shared queue for IpcIoFile, further optimize IpcIo notifications.
Dmitry Kurochkin [Tue, 26 Apr 2011 20:39:59 +0000 (00:39 +0400)] 
Rework shared queue for IpcIoFile, further optimize IpcIo notifications.

The patch implements a FewToFewBiQueue class that allows
communication between two group of processes.  The queue is used
in IpcIoFile and allows to have a single shared queue reader
state for each process (both diskers and workers).  This
continues the optimization started in r11279, see commit log for
more details.

The patch also decreases the number of shared memory segment used
by queues.  Before the change, FewToOneBiQueue used
(2*workerCount + 1) number of segments. Now FewToFewBiQueue uses
just three: for shared metadata, for array of one-to-one queues
and for array of queue readers.

14 years agoMove shared queues to Ipc namespace.
Dmitry Kurochkin [Mon, 25 Apr 2011 19:29:41 +0000 (23:29 +0400)] 
Move shared queues to Ipc namespace.

14 years agoUse shared pages in IpcIoFile instead of passing data through shared queues.
Dmitry Kurochkin [Mon, 25 Apr 2011 19:24:35 +0000 (23:24 +0400)] 
Use shared pages in IpcIoFile instead of passing data through shared queues.

14 years agoFix queue index in IpcIoFile debug message.
Dmitry Kurochkin [Mon, 25 Apr 2011 16:04:59 +0000 (20:04 +0400)] 
Fix queue index in IpcIoFile debug message.

This could lead to out of bounds array access and segfault.

14 years agoRework shared object design and management API.
Dmitry Kurochkin [Mon, 25 Apr 2011 15:14:10 +0000 (19:14 +0400)] 
Rework shared object design and management API.

Before the patch, each shared object was responsible for allocating
and deallocating shared memory it uses.  As a result each object had a
shared and non shared portion.  Shared classes provided a pair of
static methods for creating and attaching to existing shared segments.

This is against how normal objects behave: normal objects are not
responsible for managing memory they use, they use the memory they are
given.  Besides the old approach mixes shared memory management and
object initialization logic.  The patch tries to improve this.

On the user side, the patch provides two functions for managing shared
objects:

* shm_new - allocates/deallocates shared memory, initializes the object
* shm_old - gives refcounted access to the object created by shm_new

Shm_new function returns so called Owner object.  It is not used for
working with the shared object, but to do shared memory
allocation/deallocation and object initialization.  This function will
be typically used in Squid master process to allocate shared memory on
startup.  On exit, the Owner object is deleted and shared object is
deallocated.

Shm_old function returns a refcounted smart pointer to the shared
object.  It does not allocate shared memory or initialize the object,
but just points to the object owned by the Owner.  Smart pointer
provides a simple way for working with the shared object.

On the internal side, the patch removes shared memory
allocation/deallocation from shared object class.  There is no more
local/shared parts.  Shared object class implementation is now similar
to an ordinary class.  The additional requirements for "shared"
classes are: the object must be a POD with no pointers to or
references; provides a static SharedMemorySize method for shared
memory size calculation; may need to use atomic primitives for safe
updates of data members.

All existing "shared" classes and code were converted to the new API.

14 years agoRemove obsolete XXX: IpcIoMsg objects are no longer sent over UDS.
Dmitry Kurochkin [Wed, 20 Apr 2011 18:45:33 +0000 (22:45 +0400)] 
Remove obsolete XXX: IpcIoMsg objects are no longer sent over UDS.

14 years agoTemporary fix for coredumps during shutdown cleanup. take06
Alex Rousskov [Thu, 21 Apr 2011 15:19:31 +0000 (09:19 -0600)] 
Temporary fix for coredumps during shutdown cleanup.

For a permanent fix, we need to avoid deleting fd_table while it is still
in use by others, such as DeferredReads, possibly by allowing event loop
to run during shutdown.

14 years agoDisable shared memory cache when not running in SMP mode.
Alex Rousskov [Thu, 21 Apr 2011 15:13:33 +0000 (09:13 -0600)] 
Disable shared memory cache when not running in SMP mode.

14 years agoPolished debugging messages.
Alex Rousskov [Thu, 21 Apr 2011 14:46:45 +0000 (08:46 -0600)] 
Polished debugging messages.

14 years agoDrop SUID priveleges when running RunnersRegistry actions.
Dmitry Kurochkin [Thu, 21 Apr 2011 06:53:12 +0000 (10:53 +0400)] 
Drop SUID priveleges when running RunnersRegistry actions.

Before the patch, Squid created shared memory segments as root and
workers failed to attach to it as non-root.

14 years agoDo not leave a no-longer valid ThePagePool pointer behind the cleanup.
Alex Rousskov [Tue, 19 Apr 2011 22:40:17 +0000 (16:40 -0600)] 
Do not leave a no-longer valid ThePagePool pointer behind the cleanup.

14 years agoFixed compiler warnings about wrong printf() format for currentSize().
Alex Rousskov [Tue, 19 Apr 2011 22:35:32 +0000 (16:35 -0600)] 
Fixed compiler warnings about wrong printf() format for currentSize().

14 years agoMerged from parent (trunk r11387, v3.2.0.7+).
Alex Rousskov [Tue, 19 Apr 2011 22:36:00 +0000 (16:36 -0600)] 
Merged from parent (trunk r11387, v3.2.0.7+).

14 years agonegotiate_wrapper_auth: fix strict compiler warnings
Amos Jeffries [Tue, 19 Apr 2011 13:20:31 +0000 (01:20 +1200)] 
negotiate_wrapper_auth: fix strict compiler warnings

14 years agoAdjust FewToOneBiQueue to use IDs in [1, workerCount] range.
Dmitry Kurochkin [Tue, 19 Apr 2011 11:00:37 +0000 (15:00 +0400)] 
Adjust FewToOneBiQueue to use IDs in [1, workerCount] range.

This allows using KidIdentifier as queue id directly without +-1 math.

14 years agoCode polishing, s/mySharedSize/sharedSize/ for consistency.
Dmitry Kurochkin [Tue, 19 Apr 2011 05:50:31 +0000 (09:50 +0400)] 
Code polishing, s/mySharedSize/sharedSize/ for consistency.

14 years agoConvert most Segment::mem() calls to reserve().
Dmitry Kurochkin [Tue, 19 Apr 2011 05:20:17 +0000 (09:20 +0400)] 
Convert most Segment::mem() calls to reserve().

Now all shared structures properly reserve() memory.

14 years agoCleanup Pages initialization:
Dmitry Kurochkin [Tue, 19 Apr 2011 04:06:00 +0000 (08:06 +0400)] 
Cleanup Pages initialization:

* remove Pages::Init() and Pages::Attach()
* do init in SharedMemPagesRr::run()

14 years agoUnlink shared segments used by memory cache, using RunnersRegistry API.
Dmitry Kurochkin [Tue, 19 Apr 2011 03:56:16 +0000 (07:56 +0400)] 
Unlink shared segments used by memory cache, using RunnersRegistry API.

Implement static Unlink() method for Ipc::Mem::Segment and other shared
classes.

14 years agoOptimized the number of "queue is no longer empty" IpcIo notifications.
Alex Rousskov [Tue, 19 Apr 2011 04:31:53 +0000 (22:31 -0600)] 
Optimized the number of "queue is no longer empty" IpcIo notifications.

The original code relied on the writer (pusher) knowledge to decide when a
notification is needed. That code was simpler but it resulted in many
pointless notifications because the reader could have been busy processing the
last popped item and would have checked the queue after that processing
anyway. This would become especially wasteful when the reader pops multiple
requests before processing them (e.g. to do "elevator" seek optimization).

The intermediate implementation (not comitted) placed the reader state in
each queue. That was still fairly simple and worked OK, but it was not
addressing the needs of the disker readers. Diskers have many incoming
queues. If at least one incoming queue has requests, the disker is not
blocked and does not need a notification.

The last implementation allows all incoming queues of a single disker to share
the reader/disker state. The reader state is disassociated from the single
queue.  There is still some wasteful state updates when multiple queues are
iterated in FewToOneBiQueue::pop(), but their overheads should be very minor.
We need to figure out whether a single shared reader state can also be used
for workers though (each worker also has many incoming queues...).

Also added debugging and a few XXXs/TODOs to mark future work items.

14 years agoUse page-rounded size for MemStore size rather than stored size.
Dmitry Kurochkin [Mon, 18 Apr 2011 15:01:04 +0000 (19:01 +0400)] 
Use page-rounded size for MemStore size rather than stored size.

Also rename MemStore::cur_size to MemStore::theCurrentSize to avoid confusion
with the KB-based SwapDir::cur_size.

14 years agoTypos in 3.1 release notes
Amos Jeffries [Mon, 18 Apr 2011 14:42:25 +0000 (02:42 +1200)] 
Typos in 3.1 release notes

14 years agoPrint size in KB when warning about too large disk-cache maximum object size.
Dmitry Kurochkin [Mon, 18 Apr 2011 13:33:52 +0000 (17:33 +0400)] 
Print size in KB when warning about too large disk-cache maximum object size.

14 years agoDo not create shared memory pools and warn if we cannot cache a single item.
Dmitry Kurochkin [Mon, 18 Apr 2011 13:30:00 +0000 (17:30 +0400)] 
Do not create shared memory pools and warn if we cannot cache a single item.

14 years agoPrep for 3.1.12.1 and 3.2.0.7
Amos Jeffries [Mon, 18 Apr 2011 12:27:45 +0000 (06:27 -0600)] 
Prep for 3.1.12.1 and 3.2.0.7

14 years agoWarn if MemStore cannot support the configured maximum disk-cache entry size.
Dmitry Kurochkin [Mon, 18 Apr 2011 11:53:16 +0000 (15:53 +0400)] 
Warn if MemStore cannot support the configured maximum disk-cache entry size.

14 years agoImplement Ipc::Mem::Level().
Dmitry Kurochkin [Mon, 18 Apr 2011 10:37:52 +0000 (14:37 +0400)] 
Implement Ipc::Mem::Level().

14 years agoImprove statistic reporting for shared Rock caches.
Dmitry Kurochkin [Mon, 18 Apr 2011 10:28:07 +0000 (14:28 +0400)] 
Improve statistic reporting for shared Rock caches.

Rock cache is shared between multiple processes.  We need to make sure
cache related stats are not counted twice by different processes.  The
patch makes Rock store statistics to be reported by the disker process
only.

Some global variables for cache related stats are replaced with Store
class methods.  This is needed because it may be difficult or
impossible to correctly update these variables for shared caches.

The patch also fixes cache manager output for some requests like
mgr:storedir: Before the change stats from disker processes were not
surrounded with "by kidN".

14 years agoBundle pkg.m4 from pkg-config 0.25
Scott James Remnant [Mon, 18 Apr 2011 10:22:30 +0000 (22:22 +1200)] 
Bundle pkg.m4 from pkg-config 0.25

These macros are required for ./configure to run on an OS such as MingW.

The macro to detect pkg-config being present is usualy only bundled with
pkg-config. When there is no pkg-config installed ./configure will fail.
This allows our configure to detect the absence and mark some components
as unavailable or unusable.

14 years agoFix COSS build:
Dmitry Kurochkin [Sun, 17 Apr 2011 10:27:49 +0000 (14:27 +0400)] 
Fix COSS build:

* call MemAllocator::freeOne() instead of MemAllocator::free()
* add unused "how" argument to CossState::close()
* fix signed-with-unsigned comparison

14 years agoFixes NTLM and Negotiate auth assertion "RefCountCount() == 2"
Amos Jeffries [Sun, 17 Apr 2011 03:35:52 +0000 (21:35 -0600)] 
Fixes NTLM and Negotiate auth assertion "RefCountCount() == 2"

It turns out the replay cache and invalid RefCount cases this was added to
protect againt are not present anyway. After some minor cleanup to remove
double-calls in Negotiate things appear to run nicely.

NOTE:
 There is still a risk that these problem cases may in future occur, but
 meanwhile we need NTLM and Negotiate to be usable and efficient.
 The bugs resulting from those can be dealt with if/when they do occur.

14 years agonegotiate_wrapper_auth: various portability fixes
Amos Jeffries [Sat, 16 Apr 2011 14:43:18 +0000 (02:43 +1200)] 
negotiate_wrapper_auth: various portability fixes

14 years agonegotiate_wrapper_auth: version 1.0.1
Markus Moeller [Fri, 15 Apr 2011 11:51:15 +0000 (05:51 -0600)] 
negotiate_wrapper_auth: version 1.0.1

A helper to perform Negotaite authentication in both its Negotiate/NTLM
and Negotiate/Kerberos forms.
Makes use of additional Squid helpers after unwrapping the header token.

14 years agoSourceFormat Enforcement
Automatic source maintenance [Fri, 15 Apr 2011 00:12:31 +0000 (18:12 -0600)] 
SourceFormat Enforcement

14 years agoCall haveParsedReplyHeaders() before entry->replaceHttpReply().
Alex Rousskov [Thu, 14 Apr 2011 22:20:55 +0000 (16:20 -0600)] 
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.

14 years agoDo not create shared memory pools if caching is disabled.
Alex Rousskov [Thu, 14 Apr 2011 22:19:10 +0000 (16:19 -0600)] 
Do not create shared memory pools if caching is disabled.
Ipc::Mem::PagePool cannot handle zero capacity well.

14 years agoCheck that we do not overflow mmap(2) size argument.
Alex Rousskov [Thu, 14 Apr 2011 20:35:30 +0000 (14:35 -0600)] 
Check that we do not overflow mmap(2) size argument.

14 years agoPolished desired total memory size calculation.
Alex Rousskov [Thu, 14 Apr 2011 20:28:39 +0000 (14:28 -0600)] 
Polished desired total memory size calculation.

14 years agoAdded TODO to deal with page alignment.
Alex Rousskov [Thu, 14 Apr 2011 20:21:36 +0000 (14:21 -0600)] 
Added TODO to deal with page alignment.

Same may be needed (but for non-performance reasons) for
Ipc::Mem::Segment::reserve().

14 years agoUse off_t instead of int and size_t for segment sizes
Alex Rousskov [Thu, 14 Apr 2011 20:16:35 +0000 (14:16 -0600)] 
Use off_t instead of int and size_t for segment sizes
to be able to allocated larger than 4GB segments on some platforms.

Double check the newly created segment size using fstat().

14 years agoUse size_t instead of unsigned int for the page size to prevent int overflows
Alex Rousskov [Thu, 14 Apr 2011 20:12:44 +0000 (14:12 -0600)] 
Use size_t instead of unsigned int for the page size to prevent int overflows
when computing the total segment size.

Size_t is also more appropriate for memory object sizes, even though it is
very unlikely that page sizes will get bigger than an int can hold.

14 years agoMerged from parent (trunk r11379, v3.2.0.6+).
Alex Rousskov [Thu, 14 Apr 2011 16:58:28 +0000 (10:58 -0600)] 
Merged from parent (trunk r11379, v3.2.0.6+).

14 years agoPolished shared memory initialization sequence, using RunnersRegistry API.
Alex Rousskov [Thu, 14 Apr 2011 04:25:35 +0000 (22:25 -0600)] 
Polished shared memory initialization sequence, using RunnersRegistry API.

The master process is now responsible for initializing all shared memory
segments before starting kids. The kids do not create new segments and attach
to the already initialized segments instead. This approach may not scale for
ever, but it avoids more complex initialization synchronization via
Coordinator.

Do not use Strings for globals because current string memory pools do not
support early initialization.

14 years agoAdded RunnersRegistry, an API to register and, later, run a group of actions.
Alex Rousskov [Thu, 14 Apr 2011 04:22:25 +0000 (22:22 -0600)] 
Added RunnersRegistry, an API to register and, later, run a group of actions.

Useful for keeping general initialization management code (e.g., main.cc)
independent from specific initialization code (e.g., Ipc::Mem::Init) during
staged initialization and cleaning.

14 years agoSourceLayout: namesapce for Auth::User children
Amos Jeffries [Thu, 14 Apr 2011 02:40:59 +0000 (20:40 -0600)] 
SourceLayout: namesapce for Auth::User children

Also, shuffle the resulting classes into their own compilation units.

No Logic changes.
Have omitted shuffling or altering two Auth::Basic::User methods handling
the validation short-circuit since these shodul not be part of that class.
Followup patch will move them appropriately.

14 years agoCheck the limit early in hope to catch cases when it becomes zero.
Alex Rousskov [Wed, 13 Apr 2011 20:11:39 +0000 (14:11 -0600)] 
Check the limit early in hope to catch cases when it becomes zero.
We could support maps with zero limits, but they should not be needed for now.

14 years agoIncreased page size to 32KB so that most typical responses would fit
Alex Rousskov [Wed, 13 Apr 2011 19:30:46 +0000 (13:30 -0600)] 
Increased page size to 32KB so that most typical responses would fit
until we support multi-page caching.

Made cumulative page size limit configurable via cache_mem.

Implemented Ipc::Mem::Limit().

14 years agoUse size_t for cumulative shared pages limits instead of uint64_t
Alex Rousskov [Wed, 13 Apr 2011 19:28:58 +0000 (13:28 -0600)] 
Use size_t for cumulative shared pages limits instead of uint64_t
because cache_mem (Config.memMaxSize) is size_t.

14 years agoFixed comment typo.
Alex Rousskov [Wed, 13 Apr 2011 17:07:02 +0000 (11:07 -0600)] 
Fixed comment typo.

14 years agoFixed shared memory cleanup code -- we were not returning freed pages to Pages.
Alex Rousskov [Wed, 13 Apr 2011 17:03:08 +0000 (11:03 -0600)] 
Fixed shared memory cleanup code -- we were not returning freed pages to Pages.

Added Ipc::StoreMapCleaner API so that map users are notified when the slot is
about to be overwritten or freed. Users need a chance to update their state
(e.g., return the no longer used shared page) before the extra information in
the slot disappears.

14 years agoExplain why we do not implement Icp::StoreMapCleaner API (yet).
Alex Rousskov [Wed, 13 Apr 2011 17:02:23 +0000 (11:02 -0600)] 
Explain why we do not implement Icp::StoreMapCleaner API (yet).

14 years agoFixed how storeSwapOutStart() prevents repeated calls on failures.
Alex Rousskov [Wed, 13 Apr 2011 05:19:00 +0000 (23:19 -0600)] 
Fixed how storeSwapOutStart() prevents repeated calls on failures.

We used to release the entry to signal that swapout is not possible. That hack
worked for disk caching, but it prevents nearly all memory caching because
released entries cannot be cached in memory.

A polished solution is to explicitly remember whether we made the decision to
allow or reject a swapout. The decision is now stored in MemObject::SwapOut.

Call StoreEntry::checkCachable() from StoreEntry::swapoutPossible(). This
allows us to make the decision sooner in some cases. Needs more work because
some checks in the two functions overlap and "too many files" checks in
checkCachable() should not be there at all.

Added an XXX for the checkCachable() call at the end of swapout. Out of this
project scope.

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

14 years agoFixed storeDirSelectSwapDirRoundRobin iteration for the "no cache_dir" case.
Alex Rousskov [Tue, 12 Apr 2011 22:59:05 +0000 (16:59 -0600)] 
Fixed storeDirSelectSwapDirRoundRobin iteration for the "no cache_dir" case.

Moved [shared] memory cache stats reporting, addressing an old FIXME.

14 years agoAdded basic stats reporting.
Alex Rousskov [Tue, 12 Apr 2011 22:58:25 +0000 (16:58 -0600)] 
Added basic stats reporting.

14 years agoFixed Ipc::Mem::PageStack::theSize type to be signed.
Alex Rousskov [Tue, 12 Apr 2011 22:02:13 +0000 (16:02 -0600)] 
Fixed Ipc::Mem::PageStack::theSize type to be signed.
Otherwise, unsigned zero theSize underflows in pop(), causing an infinite loop.

14 years agoPolished debugging.
Alex Rousskov [Tue, 12 Apr 2011 18:56:40 +0000 (12:56 -0600)] 
Polished debugging.

14 years agoFixed Ipc::Mem::Segment::reserve().
Alex Rousskov [Tue, 12 Apr 2011 18:47:31 +0000 (12:47 -0600)] 
Fixed Ipc::Mem::Segment::reserve().
It was returning the pointer to the end of the reserved area.

Added debugging.

14 years agoFixed signed-with-unsigned compiler warnings.
Alex Rousskov [Tue, 12 Apr 2011 18:26:55 +0000 (12:26 -0600)] 
Fixed signed-with-unsigned compiler warnings.

14 years agoManager: send User-Agent header from cachemgr.cgi
Amos Jeffries [Tue, 12 Apr 2011 11:33:32 +0000 (23:33 +1200)] 
Manager: send User-Agent header from cachemgr.cgi

Uses hard-coded string "cachemgr.cgi/" instead of progname to avoid
complications from alternative names and when running under a browser.

May be elided in transit however teh VERSION sent here will help the
queried proxy respond appropriate to the CGI capabilities as we extend
the types and content of reports coming back from the future releases.

14 years agoSourceLayout: add missing CredentialState.h
Amos Jeffries [Tue, 12 Apr 2011 06:01:32 +0000 (00:01 -0600)] 
SourceLayout: add missing CredentialState.h

14 years agoAdded initial shared memory cache implementation (MemStore) and integrated it.
Alex Rousskov [Tue, 12 Apr 2011 00:33:41 +0000 (18:33 -0600)] 
Added initial shared memory cache implementation (MemStore) and integrated it.

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

There are several XXXs and TODOs that still need to be addressed for a more
polished implementation.

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.

14 years agoSourceFormat Enforcement
Automatic source maintenance [Tue, 12 Apr 2011 00:12:32 +0000 (18:12 -0600)] 
SourceFormat Enforcement

14 years agoAvoid creating unlocked store_table entries when handling rebuild conflicts.
Alex Rousskov [Mon, 11 Apr 2011 23:50:50 +0000 (17:50 -0600)] 
Avoid creating unlocked store_table entries when handling rebuild conflicts.

Such StoreEntry objects persist until a hit locks and unlocks them (or the
replacement policy removes them?), creating SMP synchronization problems
because they are treated as in-transit objects even though their store slot
may be gone already.

14 years agoAdded TODOs to avoid creating unlocked store_table entries.
Alex Rousskov [Mon, 11 Apr 2011 23:49:57 +0000 (17:49 -0600)] 
Added TODOs to avoid creating unlocked store_table entries.

14 years agoSourceLayout: namespace for Auth::User
Amos Jeffries [Mon, 11 Apr 2011 14:08:54 +0000 (08:08 -0600)] 
SourceLayout: namespace for Auth::User

No logic changes.

14 years agoImport SN.png correctly as binary.
Amos Jeffries [Mon, 11 Apr 2011 06:09:21 +0000 (18:09 +1200)] 
Import SN.png correctly as binary.

14 years agoRe-fix icons/ FHS compliance
Amos Jeffries [Mon, 11 Apr 2011 06:05:36 +0000 (18:05 +1200)] 
Re-fix icons/ FHS compliance

It seems I was working out of an outdated copy of the FHS.
Current standards describe /var/www as deprecated.

Reverting the icons location back to where it started.

14 years agoSourceLayout: Shuffle InitAuthSchemes() to Auth::Init()
Amos Jeffries [Mon, 11 Apr 2011 03:25:32 +0000 (21:25 -0600)] 
SourceLayout: Shuffle InitAuthSchemes() to Auth::Init()

No logic changes.

14 years agoSourceFormat Enforcement
Automatic source maintenance [Mon, 11 Apr 2011 00:12:56 +0000 (18:12 -0600)] 
SourceFormat Enforcement

14 years agoBug 3183: Invalid URL accepted with url host part of only '@'.
Amos Jeffries [Sun, 10 Apr 2011 02:00:38 +0000 (14:00 +1200)] 
Bug 3183: Invalid URL accepted with url host part of only '@'.

3.0 results in an ICAP segfault handling these URLs.

Newer releases do not segfault as easily, but still accept the invalid
URL and there may be other unknown side-effects.

Makes the URL parser present ERR_INVALID_URL for this edge case.

14 years agoSourceLayout: namespace for Auth::Config children
Amos Jeffries [Sun, 10 Apr 2011 01:31:59 +0000 (19:31 -0600)] 
SourceLayout: namespace for Auth::Config children

No Logic changes.

Also, no code shuffling which should normally have been done with namespace.
Config children are currently too intwined with UserRequest children and
helper management. Logic changes are required before that can be done.

14 years agoPortability: allow GnuRegex to use libcompat min()/max()
Amos Jeffries [Sat, 9 Apr 2011 13:31:29 +0000 (01:31 +1200)] 
Portability: allow GnuRegex to use libcompat min()/max()

14 years agoPortability: aio.h suffers from GCC-specific hacks on Linux 64-bit
Amos Jeffries [Sat, 9 Apr 2011 06:36:51 +0000 (18:36 +1200)] 
Portability: aio.h suffers from GCC-specific hacks on Linux 64-bit

64-bit file support on 32-bit systems uses GCC-specific #define to convert
the functions to 64-bit API but omits the struct aiocb passed as paremeter.

GCC seems not to mind, but non-GCC compilers barf on the invalid types.

14 years agoSourceLayout: namespace for Auth::Config
Amos Jeffries [Sat, 9 Apr 2011 04:25:23 +0000 (22:25 -0600)] 
SourceLayout: namespace for Auth::Config

Also renames symbol Auth::authConfig to Auth::ConfigVector to clarify
that it is a vector<> of Auth::Config objects or children.

No logic changes.

14 years agoSplit Rock-only Rock::DirMap into Rock::DirMap and reusable Ipc pieces
Alex Rousskov [Sat, 9 Apr 2011 04:24:06 +0000 (22:24 -0600)] 
Split Rock-only Rock::DirMap into Rock::DirMap and reusable Ipc pieces
which a shared memory cache implementation can use:

Ipc::StoreMap is responsible for maintaining a collection of lockable slots,
each with readable/writeable/free state and a "waiting to be free" flag. Kids
of this class can add more metadata (in parallel structures using the same
index as primary slots). I tried extending the slots themselves, but that
turned out to be more complex/messy.

Ipc::ReadWriteLock is a basic multiple readers, single writer lock.  Its
earlier implementation inside Rock::DirMap mixed slot locking and slot
state/flags. That simplified the caller code a little, but the current simpler
class is easier to understand and reuse.

Rock::DirMap now just adds Rock::DbCellHeader metadata to Ipc::StoreMap slots.

Simplified mapping API by reducing the number of similar-but-different
methods. For example, instead of putAt, the caller can use an
openForWriting/closeForWriting pair. This helps with moving custom metadata
manipulations outside of the reusable Ipc::StoreMap.

It would be possible to split Ipc::StoreMap further by moving Store-specific
bits outside of its slots. Currently, there is no need for that though.

14 years agoAdded reserve() method to allow nested classes or similar related users of
Alex Rousskov [Sat, 9 Apr 2011 04:20:21 +0000 (22:20 -0600)] 
Added reserve() method to allow nested classes or similar related users of
the same segment to safely bite off pieces of the same shared segment. Still
need to convert the callers.

The reserve() method is useful for single-users as well because it allows
to check that a segment has enough bytes allocated for its single user.

Changed theSize type from int to "size of any single object in RAM" size_t.

14 years agoBug 3192: comm.cc:216: "fd_table[fd].halfClosedReader != NULL"
Alex Rousskov [Sat, 9 Apr 2011 04:01:00 +0000 (22:01 -0600)] 
Bug 3192: comm.cc:216: "fd_table[fd].halfClosedReader != NULL"
Polished request reading code to fix CONNECT double-read assertion.

ConnStateData::flags.readMoreRequests, do_next_read variables, and
ClientSocketContext::mayUseConnection() methods were used (or unused!)
incorrectly or inconsistently.

This change removes all do_next_read variables to simplify the state. Instead,
the renamed ConnStateData::flags.readMore indicates whether client_side.cc
should call comm_read. The mayUseConnection() methods are now used to indicate
whether the next client-sent byte (buffered or read) should be reserved for
the current request rather than being interpreted as the beginning of the next
request.

Usually,
                      flags.readMore  mayUseConnection
      basic requests:     true             false
requests with bodies:     true             true
  malformed requests:     false            false
             tunnels:     false            true

14 years agoPortability: a bit more dirent_t in squidpurge tool
Amos Jeffries [Sat, 9 Apr 2011 03:23:50 +0000 (15:23 +1200)] 
Portability: a bit more dirent_t in squidpurge tool

14 years agoBug 3194: selinux may prevent ntlm_smb_lm_auth from using /tmp
David Hill [Sat, 9 Apr 2011 02:37:59 +0000 (14:37 +1200)] 
Bug 3194: selinux may prevent ntlm_smb_lm_auth from using /tmp

14 years agoBug 3185: 3.1.11 fails to compile on OpenBSD 4.8 and 4.9
Amos Jeffries [Fri, 8 Apr 2011 13:15:03 +0000 (01:15 +1200)] 
Bug 3185: 3.1.11 fails to compile on OpenBSD 4.8 and 4.9

14 years agoPortability: and dirent_t also only matters for non-GCC.
Amos Jeffries [Fri, 8 Apr 2011 12:31:09 +0000 (00:31 +1200)] 
Portability: and dirent_t also only matters for non-GCC.

14 years agoPortability: dirent_t cannot be a typedef
Amos Jeffries [Fri, 8 Apr 2011 02:37:19 +0000 (14:37 +1200)] 
Portability: dirent_t cannot be a typedef

14 years agoSourceFormat Enforcement
Automatic source maintenance [Fri, 8 Apr 2011 00:12:34 +0000 (18:12 -0600)] 
SourceFormat Enforcement

14 years agoUsed one-for-all constant page size for now; need to be made configurable.
Alex Rousskov [Fri, 8 Apr 2011 00:08:15 +0000 (18:08 -0600)] 
Used one-for-all constant page size for now; need to be made configurable.

14 years agoFixed raw page buffer type.
Alex Rousskov [Fri, 8 Apr 2011 00:07:18 +0000 (18:07 -0600)] 
Fixed raw page buffer type.

14 years agoPortability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit'
Amos Jeffries [Thu, 7 Apr 2011 14:52:13 +0000 (02:52 +1200)] 
Portability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit'

On Linux (at least) with large file support but not full 64-bit environment.

The getrlimt / setrlimit are #define'd to getrlimite64 / setrlimit64
BUT, the struct rlimit internal fields are updated to 64-bit types individually
instead of a matching #define to struct rlimit64 as a whole.

One can only assume that GCC is casting to void* or some such major voodoo
which hides this type collision.

14 years agoPortability: glob.h requires GCC to compile on Linux.
Amos Jeffries [Thu, 7 Apr 2011 13:41:25 +0000 (01:41 +1200)] 
Portability: glob.h requires GCC to compile on Linux.

14 years agoEnable MemBlob to use the services of MemPools.
Francesco Chemolli [Thu, 7 Apr 2011 13:26:54 +0000 (15:26 +0200)] 
Enable MemBlob to use the services of MemPools.

Ensure that MemBlobs use MemPools manage memory areas, and remove
duplication of code with MemPools.

14 years agoICC: size_t is guaranteed to be >=0
Amos Jeffries [Thu, 7 Apr 2011 12:42:02 +0000 (00:42 +1200)] 
ICC: size_t is guaranteed to be >=0

14 years agoICC: support 64-bit environments dirent definitions
Amos Jeffries [Thu, 7 Apr 2011 11:58:46 +0000 (23:58 +1200)] 
ICC: support 64-bit environments dirent definitions

struct dirent is not consistently defined for 32-bit and 64-bit enabled
environments. Provide a dirent_t type defined appropriate to the environment
for use instead.

14 years agoFix ModPoll signedness checks
Amos Jeffries [Thu, 7 Apr 2011 09:23:06 +0000 (21:23 +1200)] 
Fix ModPoll signedness checks

This npending test bug was preventing any poll() errors from being
noticed and displayed. Possibly leading to some of the weird hanging
reports we have been unable to replicate.

14 years agoSourceFormat Enforcement
Automatic source maintenance [Thu, 7 Apr 2011 00:18:17 +0000 (18:18 -0600)] 
SourceFormat Enforcement

14 years agoExtend the number and size of String MemPools
Francesco Chemolli [Wed, 6 Apr 2011 22:45:40 +0000 (00:45 +0200)] 
Extend the number and size of String MemPools

Define and enable 512-bytes, 1kb, 4kb and 16kb mempooled strings
to cover expected upcoming uses

14 years agoFixed chunked request forwarding in ICAP REQMOD presence.
Alex Rousskov [Wed, 6 Apr 2011 16:25:36 +0000 (10:25 -0600)] 
Fixed chunked request forwarding in ICAP REQMOD presence.

ICAP prohibits forwarding of hop-by-hop headers in HTTP headers. If the virgin
request has a "Transfer-Encoding: chunked" header, the ICAP server will not
receive it. Thus, when the ICAP server responds with a 200 OK and what it
thinks is a copy of the HTTP request, the adapted request will be missing the
Transfer-Encoding header.

One the server side, Squid used to test whether the request had a
Transfer-Encoding header to determine whether request chunking is needed when
talking to the next HTTP hop. That test would fail in ICAP REQMOD presence.

This change implements a more direct/robust check: if we do not know the
request content length, we chunk the request.

We also no longer forward the Content-Length header if we are chunking. It
should not really be there in most cases, but an explicit check is safer and
may also prevent request smuggling attacks via Connection: Content-Length
tricks.

14 years agoPortability: Provide stdio wrappers for 64-bit in cstdio C++ builds
Francesco Chemolli [Wed, 6 Apr 2011 13:58:14 +0000 (01:58 +1200)] 
Portability: Provide stdio wrappers for 64-bit in cstdio C++ builds

stdio.h in that case on provides fgetpos64, fopen64 if
__USE_FILE_OFFSET64 is defined. It then checks whether a gcc-specific
 __REDIRECT macro is available (defined in sys/cdefs.h, depending on
__GNUC__ begin available).

If it is not available, it does a preprocessor #define.

Which <cstdio> undefines, with this comment:
 "// Get rid of those macros defined in <stdio.h> in lieu of real functions.".
When it does a namespace redirection ("namespace std { using ::fgetpos; }")
it goes blam, as fgetpos64 is available, while fgetpos is not.

To fix it, we need to supply global functions matching those
signatures (not macros).

e.g.

#include <stdio.h>
#if defined(__USE_FILE_OFFSET64) &&!defined(__REDIRECT) && defined(fgetpos)
#undef fgetpos
int fgetpos (FILE * f, fpos64_t *p) { return fgetpos64(f,p); }
#endif
#include <cstdio>

This every time we use <cstdio> (directly or indirectly).

This is triggered by us defining -D_FILE_OFFSET_BITS=64 when
--enable-large-files configure is used.

14 years agoInitial shared memory pages implementation.
Dmitry Kurochkin [Wed, 6 Apr 2011 13:23:03 +0000 (17:23 +0400)] 
Initial shared memory pages implementation.

14 years agoEnable string mempools to work correctly during initialization phase
Francesco Chemolli [Wed, 6 Apr 2011 10:40:10 +0000 (12:40 +0200)] 
Enable string mempools to work correctly during initialization phase

Makes string mempools work before Mem::Init() was called, as may happen
during global variable initialization or early main.cc processing. If
needed, strings allocated before the Mem::Init() call are given an extra
buffer space to make sure the allocated buffer size will not match any
string pool size during deallocation.
Shortcomings: We now waste RAM on buffer increase for early allocated
strings unless they are already bigger than the maximum supported string
pool size. Statistics for early allocations are broken. Non-string
mempools still do not support early allocations.