]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
8 years agoCollapse internal revalidation requests (SMP-unaware caches).
Eduard Bagdasaryan [Sat, 23 Jul 2016 13:36:56 +0000 (01:36 +1200)] 
Collapse internal revalidation requests (SMP-unaware caches).

... also address Bug 4311 and partially address Bug 2833 and Bug 4471.

Extend collapsed_forwarding functionality to internal revalidation
requests. This implementation does not support Vary-controlled cache
objects and is limited to SMP-unaware caching environments, where each
Squid worker knows nothing about requests and caches handled by other
workers. However, it also lays critical groundwork for future SMP-aware
collapsed revalidation support.

Prior to these changes, multiple concurrent HTTP requests for the same
stale cached object always resulted in multiple internal revalidation
requests sent by Squid to the origin server. Those internal requests
were likely to result in multiple competing Squid cache updates, causing
cache misses and/or more internal revalidation requests, negating
collapsed forwarding savings.

Internal cache revalidation requests are collapsed if and only if
collapsed_forwarding is enabled. There is no option to control just
revalidation collapsing because there is no known use case for it.

* Public revalidation keys

Each Store entry has a unique key. Keys are used to find entries in the
Store (both already cached/swapped_out entries and not). Public keys are
normally tied to the request method and target URI. Same request
properties normally lead to the same public key, making cache hits
possible. If we were to calculate a public key for an internal
revalidation request, it would have been the same as the public key of
the stale cache entry being revalidated. Adding a revalidation response
to Store would have purged that being-revalidated cached entry, even if
the revalidation response itself was not cachable.

To avoid purging being-revalidated cached entries, the old code used
private keys for internal revalidation requests. Private keys are always
unique and cannot accidentally purge a public entry. On the other hand,
for concurrent [revalidation] requests to find the store entry to
collapse on, that store entry has to have a public key!

We resolved this conflict by adding "scope" to public keys:

* Regular/old public keys have default empty scope (that does not affect
  key generation). The code not dealing with collapsed revalidation
  continues to work as before. All entries stored in caches continue to
  have the same keys (with an empty scope).

* When collapsed forwarding is enabled, collapsable internal
  revalidation requests get public keys with a "revalidation" scope
  (that is fed to the MD5 hash when the key is generated). Such a
  revalidation request can find a matching store entry created by
  another revalidation request (and collapse on it), but cannot clash
  with the entry being revalidated (because that entry key is using a
  different [empty] scope).

This change not only enables collapsing of internal revalidation
requests within one worker, but opens the way for SMP-aware workers to
share information about collapsed revalidation requests, similar to how
those workers already share information about being-swapped-out cache
entries.

After receiving the revalidation response, each collapsed revalidation
request may call updateOnNotModified() to update the stale entry [with
the same revalidation response!]. Concurrent entry updates would have
wasted many resources, especially for disk-cached entries that support
header updates, and may have purged being-revalidated entries due to
locking conflicts among updating transactions. To minimize these
problems, we adjusted header and entry metadata updating logic to skip
the update if nothing have changed since the last update.

Also fixed Bug 4311: Collapsed forwarding deadlocks for SMP Squids using
SMP-unaware caches. Collapsed transactions stalled without getting a
response because they were waiting for the shared "transients" table
updates. The table was created by Store::Controller but then abandoned (not
updated) by SMP-unaware caches. Now, the transients table is not created
at all unless SMP-aware caches are present. This fix should also address
complaints about shared memory being used for Squid instances without
SMP-aware caches.

A combination of SMP-aware and SMP-unaware caches is still not supported
and is likely to stall collapsed transactions if they are enabled. Note
that, by default, the memory cache is SMP-aware in SMP environments.

8 years agoQuieten digest oversize warnings
Amos Jeffries [Sat, 23 Jul 2016 06:02:56 +0000 (18:02 +1200)] 
Quieten digest oversize warnings

8 years agoSourceFormat Enforcement
Source Maintenance [Sat, 23 Jul 2016 00:12:14 +0000 (00:12 +0000)] 
SourceFormat Enforcement

8 years agoFix some failed transactions not being logged.
Eduard Bagdasaryan [Fri, 22 Jul 2016 19:37:12 +0000 (07:37 +1200)] 
Fix some failed transactions not being logged.

There are situations when Squid logs nothing to access.log after an
[abnormal] transaction termination. Such "stealthy" transactions may be
a security risk and an accounting problem.

ClientHttpRequest is responsible for logging most transactions but that
object is created only after the HTTP request headers are successfully
parsed. Request header parsing errors may be detected and logged
appropriately, but the job handling the incoming transaction may
terminate for reasons outside the parsing code control (e.g., a job-
killing exception thrown when there are no request headers to start
parsing yet or when the job waits for more request headers to finishing
parsing).

This change adds access logging for three cases:

1. accept(2) system call errors (before ConnStateData job is created).

2. Unexpected ConnStateData job termination, when there is no
   ClientHttpRequest to log the failure.

3. Connections which send no bytes: these connections drain Squid
   resources and, hence, should be logged.
   TODO: make this behavior configurable because some browsers are known to
   routinely create such connections(and, hence, logging them may create
   too much noise in some environments).

8 years agoAdd stub for log/liblog symbols
Amos Jeffries [Fri, 22 Jul 2016 13:19:36 +0000 (01:19 +1200)] 
Add stub for log/liblog symbols

8 years agoAdd missing 'tls' option for cache_peer
Amos Jeffries [Fri, 22 Jul 2016 08:38:30 +0000 (20:38 +1200)] 
Add missing 'tls' option for cache_peer

8 years agoCleanup: remove XSTD_USE_LIBLTDL, which has not been needed in a long while.
Amos Jeffries [Wed, 20 Jul 2016 14:33:14 +0000 (02:33 +1200)] 
Cleanup: remove XSTD_USE_LIBLTDL, which has not been needed in a long while.

8 years agoRevert changes in rev.14726
Amos Jeffries [Mon, 18 Jul 2016 12:36:38 +0000 (00:36 +1200)] 
Revert changes in rev.14726

8 years agoCleanup: drop redundant parse buffer check
Eduard Bagdasaryan [Sun, 17 Jul 2016 09:03:05 +0000 (21:03 +1200)] 
Cleanup: drop redundant parse buffer check

8 years agoFix error: taking the absolute value of unsigned type after rev.14739
Amos Jeffries [Sat, 16 Jul 2016 11:13:00 +0000 (23:13 +1200)] 
Fix error: taking the absolute value of unsigned type after rev.14739

8 years agoSourceFormat Enforcement
Source Maintenance [Fri, 15 Jul 2016 18:12:18 +0000 (18:12 +0000)] 
SourceFormat Enforcement

8 years agoCleanup: remove unused references to SquidList.h
Amos Jeffries [Fri, 15 Jul 2016 13:13:03 +0000 (01:13 +1200)] 
Cleanup: remove unused references to SquidList.h

8 years agoCleanup: use std::queue for UFS file I/O queues
Amos Jeffries [Fri, 15 Jul 2016 13:09:18 +0000 (01:09 +1200)] 
Cleanup: use std::queue for UFS file I/O queues

8 years agoCleanup: TunnelStateData switchToTunnel function
Amos Jeffries [Wed, 13 Jul 2016 12:59:17 +0000 (00:59 +1200)] 
Cleanup: TunnelStateData switchToTunnel function

8 years agoCleanup: PeerConnector session initialization method
Amos Jeffries [Wed, 13 Jul 2016 12:39:22 +0000 (00:39 +1200)] 
Cleanup: PeerConnector session initialization method

* rename initializeSsl() method to initializeTls()

* use SessionPointer instead of SessionPtr

* return value is best used in boolean expressions, so make it bool
  this also resolves some template issues with SessionPointer return type.

* rename the session parameter to serverSession which better documents what
  it is than 'ssl', and distinguishes it from clientSession in child methods
  which have to deal with both.

8 years agoFix error: 'storeDigestRegisterWithCacheManager' was not declared
Amos Jeffries [Wed, 13 Jul 2016 11:31:50 +0000 (23:31 +1200)] 
Fix error: 'storeDigestRegisterWithCacheManager' was not declared

8 years agoBug 4534: assertion failure in xcalloc when using many cache_dir
Amos Jeffries [Tue, 12 Jul 2016 16:15:51 +0000 (04:15 +1200)] 
Bug 4534: assertion failure in xcalloc when using many cache_dir

8 years agoCleanup: Ssl::Create*() functions
Amos Jeffries [Mon, 11 Jul 2016 10:57:11 +0000 (22:57 +1200)] 
Cleanup: Ssl::Create*() functions

* return value is only used in boolean expressions, so make it bool

* pass Comm::ConnectionPointer instead of raw-FD value

8 years agobasic_db_auth: add support for unsalted SHA1 passwords
jltallon [Fri, 8 Jul 2016 12:30:01 +0000 (00:30 +1200)] 
basic_db_auth: add support for unsalted SHA1 passwords

8 years agoSourceFormat Enforcement
Source Maintenance [Fri, 8 Jul 2016 12:12:14 +0000 (12:12 +0000)] 
SourceFormat Enforcement

8 years agoReplaced TidyPointer with std::unique_ptr.
Amos Jeffries [Fri, 8 Jul 2016 11:26:40 +0000 (23:26 +1200)] 
Replaced TidyPointer with std::unique_ptr.

LockingPointer is now a stand-alone class that is understood (and
documented) as a typical shared pointer with OpenSSL-friendly object
importing methods. Replaced its TidyPointer::reset() abuse with an
explicit resetWithoutLocking() method after reviewing that all such
calls needed no locking indeed.

8 years agoPolish from final audit
Amos Jeffries [Fri, 8 Jul 2016 06:24:33 +0000 (18:24 +1200)] 
Polish from final audit

8 years agoMerged from trunk rev.14734
Amos Jeffries [Thu, 7 Jul 2016 19:03:02 +0000 (07:03 +1200)] 
Merged from trunk rev.14734

9 years agoReplace LockingPointer::reset with resetWithoutLocking
Amos Jeffries [Tue, 5 Jul 2016 23:37:12 +0000 (11:37 +1200)] 
Replace LockingPointer::reset with resetWithoutLocking

This required the GnuTLS and void session pointer definitions being made
to use LockingPointer.

Also, use std::move assignment instead of X.reset(Y.release()) pattern.

9 years agoCleanup: make createStaticServerContext deal with ContextPointer
Amos Jeffries [Tue, 5 Jul 2016 17:00:36 +0000 (05:00 +1200)] 
Cleanup: make createStaticServerContext deal with ContextPointer

This method is about initializing the staticContext member of
ServerOptions. There is no need to involve the caller directly in those
logistics.

9 years agoBug 4542: authentication credentials IP TTL updated incorrectly
Anonymous [Tue, 5 Jul 2016 05:45:44 +0000 (17:45 +1200)] 
Bug 4542: authentication credentials IP TTL updated incorrectly

9 years agoUpdate LockingPointer methods and documentation
Amos Jeffries [Mon, 4 Jul 2016 15:21:08 +0000 (03:21 +1200)] 
Update LockingPointer methods and documentation

9 years agoBug 4540: revert r14720 buffer update
Amos Jeffries [Sat, 2 Jul 2016 06:47:55 +0000 (18:47 +1200)] 
Bug 4540: revert r14720 buffer update

9 years agoAdd missing dereference operator in TidyPointer
Amos Jeffries [Fri, 1 Jul 2016 17:35:00 +0000 (05:35 +1200)] 
Add missing dereference operator in TidyPointer

9 years ago4.0.12 SQUID_4_0_12
Amos Jeffries [Fri, 1 Jul 2016 13:25:33 +0000 (01:25 +1200)] 
4.0.12

9 years agoSourceFormat Enforcement
Source Maintenance [Fri, 1 Jul 2016 12:12:10 +0000 (12:12 +0000)] 
SourceFormat Enforcement

9 years agoPrep for 4.0.12 and 3.5.20
Amos Jeffries [Fri, 1 Jul 2016 11:30:00 +0000 (23:30 +1200)] 
Prep for 4.0.12 and 3.5.20

9 years agoAdd missing STUBS for rev.14726
Amos Jeffries [Fri, 1 Jul 2016 11:12:09 +0000 (23:12 +1200)] 
Add missing STUBS for rev.14726

9 years agoGnuTLS: support for TLS session resume
Amos Jeffries [Thu, 30 Jun 2016 22:10:55 +0000 (10:10 +1200)] 
GnuTLS: support for TLS session resume

9 years agoBug 4523: smblib compile fails on NetBSD
Ian Clark [Thu, 30 Jun 2016 19:33:14 +0000 (07:33 +1200)] 
Bug 4523: smblib compile fails on NetBSD

9 years agoPolish: remove unnecessary 'this->' usage in LockingPointer
Amos Jeffries [Thu, 30 Jun 2016 18:10:33 +0000 (06:10 +1200)] 
Polish: remove unnecessary 'this->' usage in LockingPointer

9 years agoCleanup: use C++11 auto when starting ::Server jobs
Amos Jeffries [Thu, 30 Jun 2016 12:37:25 +0000 (00:37 +1200)] 
Cleanup: use C++11 auto when starting ::Server jobs

9 years agoBug 4376: clang cannot build Squid eCAP code
Patrick Welche [Wed, 29 Jun 2016 17:24:24 +0000 (11:24 -0600)] 
Bug 4376: clang cannot build Squid eCAP code

This change is not needed for libecap v1.0 that uses tr1::shared_ptr.
However, libecap is being updated to use std::shared_ptr. Once that
update is complete, Squid eCAP code will no longer compile because the
implicit conversion of shared_ptr to bool in tr1 was deemed dangerous
and, hence, made "explicit" when shared_ptr became standard. Unlike "if"
statements, "return" statements do not trigger an explicit conversion.

9 years agoRemove UnaryFunctor as well, use std::function instead
Amos Jeffries [Wed, 29 Jun 2016 10:44:40 +0000 (22:44 +1200)] 
Remove UnaryFunctor as well, use std::function instead

9 years agosecurity_file_certgen: convert xfree_char to UnaryFunctor xfree_functor
Amos Jeffries [Tue, 28 Jun 2016 12:57:49 +0000 (00:57 +1200)] 
security_file_certgen: convert xfree_char to UnaryFunctor xfree_functor

9 years agoRename UniaryFunctor to UnaryFunctor
Amos Jeffries [Tue, 28 Jun 2016 12:37:16 +0000 (00:37 +1200)] 
Rename UniaryFunctor to UnaryFunctor

9 years agoClang does not provide a global nullptr_t symbol
Amos Jeffries [Mon, 27 Jun 2016 15:54:25 +0000 (03:54 +1200)] 
Clang does not provide a global nullptr_t symbol

9 years agoMerge form trunk rev.14722
Amos Jeffries [Sun, 26 Jun 2016 15:30:29 +0000 (03:30 +1200)] 
Merge form trunk rev.14722

9 years agoFix build error in ESI after rev.14721
Amos Jeffries [Sun, 26 Jun 2016 15:29:44 +0000 (03:29 +1200)] 
Fix build error in ESI after rev.14721

9 years agoMerged from trunk rev.14721
Amos Jeffries [Sun, 26 Jun 2016 14:11:59 +0000 (02:11 +1200)] 
Merged from trunk rev.14721

9 years agoRename CtoCppDtor() as UniaryFunctor()
Amos Jeffries [Sun, 26 Jun 2016 10:41:32 +0000 (22:41 +1200)] 
Rename CtoCppDtor() as UniaryFunctor()

Update the filename, and output functor name suffix to match.

9 years agoRemove last remains of TidyPointer
Amos Jeffries [Sat, 25 Jun 2016 18:02:09 +0000 (06:02 +1200)] 
Remove last remains of TidyPointer

9 years agoRestore old move-assignment definition
Amos Jeffries [Sat, 25 Jun 2016 15:23:43 +0000 (03:23 +1200)] 
Restore old move-assignment definition

We cannot use the compilers default move assignment operator since we
have custom deletePointer() happening in the reset() call.

9 years agoHTTP/1.1: Update all stored headers on 304 revalidation.
Eduard Bagdasaryan [Sat, 25 Jun 2016 14:35:41 +0000 (02:35 +1200)] 
HTTP/1.1: Update all stored headers on 304 revalidation.

According to RFC 7234 section 4.3.4. when a proxy receives 304 (Not Modified)
response, it should update every header, except Warning headers (which need
special processing). Also RFC 7232 section 4.1. does not prohibit origin servers
from sending any headers in 304 responses. That means that Squid now should not
ignore headers, which earlier were considered as malicious/faulty.

9 years agoMigrate TidyPointer to std::unique_ptr
Amos Jeffries [Fri, 24 Jun 2016 12:32:41 +0000 (00:32 +1200)] 
Migrate TidyPointer to std::unique_ptr

9 years agosecurity_file_certgen: use std::unique_ptr instead of TidyPointer
Amos Jeffries [Fri, 24 Jun 2016 12:01:31 +0000 (00:01 +1200)] 
security_file_certgen: use std::unique_ptr instead of TidyPointer

9 years agoConvert Http::Stream::reqbuf to a MemBlob, making it configurable at runtime.
Nathan Hoad [Fri, 24 Jun 2016 05:29:44 +0000 (17:29 +1200)] 
Convert Http::Stream::reqbuf to a MemBlob, making it configurable at runtime.

This also makes many other auxilary changes:

 * Increases the size of Http::Stream::requestBuffer to match that of
   read_ahead_gap. Previously this was a 4kb fixed size buffer. As a result,
   the overhead for a single client connection has been increased by 12 KB in
   the default configuration, but Squid will no longer artifically slow down
   client responses in this situation by fragmenting the read(2)/write(2)
   calls.

 * Improves the performance of large uncacheable replies. This was achieved by
   increasing the buffer size to 16 KB as mentioned above, but it is worth
   mentioning separately. Specifically, for a server, client and proxy all
   running on my local machine, this patch increases throughput on a 5 GB file
   from ~110 MB/s to ~340 MB/s.

 * Documents the influence that read_ahead_gap had on the size of read(2) calls
   for HTTP, and now the size of write(2) calls.

 * Prevent read_ahead_gap from being set to 0. Previously this would result in
   hung requests.

This work is submitted on behalf of Bloomberg L.P.

9 years agoCleanup: separate TidyPointer and LockingPointer
Amos Jeffries [Thu, 23 Jun 2016 17:05:30 +0000 (05:05 +1200)] 
Cleanup: separate TidyPointer and LockingPointer

By cut-n-pasting the TidyPointer API into LockingPointer
and removing the inheritence.

9 years agoSync with trunk rev.14719
Amos Jeffries [Thu, 23 Jun 2016 02:08:56 +0000 (14:08 +1200)] 
Sync with trunk rev.14719

9 years agoWipe initial experiments
Amos Jeffries [Thu, 23 Jun 2016 02:07:23 +0000 (14:07 +1200)] 
Wipe initial experiments

9 years agoBug 4532: pid_filename not working as documented
Amos Jeffries [Mon, 20 Jun 2016 12:50:59 +0000 (00:50 +1200)] 
Bug 4532: pid_filename not working as documented

9 years agoSourceFormat Enforcement
Source Maintenance [Fri, 17 Jun 2016 18:12:11 +0000 (18:12 +0000)] 
SourceFormat Enforcement

9 years agoAssertion failed: Write.cc:38: "fd_table[conn->fd].flags.open"
Christos Tsantilas [Fri, 17 Jun 2016 17:37:22 +0000 (20:37 +0300)] 
Assertion failed: Write.cc:38: "fd_table[conn->fd].flags.open"

The Ftp::Server::stopWaitingForOrigin() notification may come after
Ftp::Server (or an external force) has started closing the control
connection but before the Ftp::Server job became unreachable for
notifications. Writing a response in this state leads to assertions.

Other, currently unknown paths may lead to the same write-after-close
problems. This change protects all asynchronous notification methods
(except the connection closure handler itself) from exposing underlying
code to a closing control connection. This is very similar to checking
for ERR_CLOSING in Comm handlers.

This is a Measurement Factory project.

9 years agoRemove impossible condition from rev.14715
Amos Jeffries [Fri, 17 Jun 2016 17:13:44 +0000 (05:13 +1200)] 
Remove impossible condition from rev.14715

9 years agoUnit test for SBuf::reserve()
Amos Jeffries [Fri, 17 Jun 2016 16:29:29 +0000 (04:29 +1200)] 
Unit test for SBuf::reserve()

9 years agoDo not make bogus recvmsg(2) calls when closing UDS sockets.
Alex Rousskov [Wed, 15 Jun 2016 15:37:44 +0000 (09:37 -0600)] 
Do not make bogus recvmsg(2) calls when closing UDS sockets.

comm_empty_os_read_buffers() assumes that all non-blocking
FD_READ_METHODs can read into an opaque buffer filled with random
characters. That assumption is wrong for UDS sockets that require an
initialized msghdr structure. Feeding random data to recvmsg(2) leads to
confusing errors, at best. Squid does not log those errors, but they
are visible in, for example, strace:

  recvmsg(17, 0x7fffbb, MSG_DONTWAIT) = -1 EMSGSIZE (Message too long)

comm_empty_os_read_buffers() is meant to prevent TCP RST packets. The
function now ignores UDS sockets that are not used for TCP.

TODO: Useless reads may also exist for UDP and some TCP sockets.

9 years agoBug 4504: Too many WARNING: Ignoring error setting CA certificate locations
Amos Jeffries [Wed, 15 Jun 2016 14:31:34 +0000 (02:31 +1200)] 
Bug 4504: Too many WARNING: Ignoring error setting CA certificate locations

9 years agoSourceFormat Enforcement
Source Maintenance [Tue, 14 Jun 2016 18:12:14 +0000 (18:12 +0000)] 
SourceFormat Enforcement

9 years agoBug 4516: security_file_certgen man page update
Marcos Mello [Tue, 14 Jun 2016 17:36:04 +0000 (05:36 +1200)] 
Bug 4516: security_file_certgen man page update

9 years agoFixed Server::maybeMakeSpaceAvailable() logic.
Alex Rousskov [Tue, 14 Jun 2016 16:54:23 +0000 (04:54 +1200)] 
Fixed Server::maybeMakeSpaceAvailable() logic.

This change fixes logic bugs that mostly affect performance: In micro-
tests, this change gives 10% performance improvement for intercepted
"fast peek at SNI and splice" SslBump configurations. Similar
improvement is expected for future plain HTTP/2 parsers.

maybeMakeSpaceAvailable() is called with an essentially random inBuf.
The method must prepare inBuf for the next network read. The old code
was not doing that [well enough], leading to performance problems.

In some environments, inBuf often ends up having tiny space exceeding 2
bytes (e.g., 6 bytes). This happens, for example, when Squid creates and
parses a fake CONNECT request. The old code often left such tiny inBufs
"as is" because we tried to ensure that we have at least 2 bytes to read
instead of trying to provide a reasonable number of buffer space for the
next network read. Tiny buffers naturally result in tiny network reads,
which are very inefficient, especially for non-incremental parsers.

I have removed the explicit "2 byte" space checks: Both the new and the
old code do not _guarantee_ that at least 2 bytes of buffer space are
always available, and the caller does not check that condition either.
If some other code relies on it, more fixes will be needed (but this
change is not breaking that guarantee -- either it was broken earlier or
was never fully enforced). In practice, only buffers approaching
Config.maxRequestBufferSize limit may violate this guarantee AFAICT, and
those buffers ought to be rare, so the bug, if any, remains unnoticed.

Another subtle maybeMakeSpaceAvailable() problem was that the code
contained its own buffer capacity increase algorithm (n^2 growth).
However, increasing buffer capacity exponentially does not make much
sense because network read sizes are not going to increase
exponentially. Also, memAllocStringmemAllocate() overwrites n^2 growth
with its own logic. Besides, it is buffer _space_, not the total
capacity that should be increased. More work is needed to better match
Squid buffer size for from-user network reads with the TCP stack buffers
and traffic patterns.

Both the old and the new code reallocate inBuf MemBlobs. However, the
new code leaves "reallocate or memmove" decision to the new
SBuf::reserve(), opening the possibility for future memmove
optimizations that SBuf/MemBlob do not currently support.

It is probably wrong that inBuf points to an essentially random MemBlob
outside Server control but this change does not attempt to fix that.

9 years agoTLS Authority Key Identifier certificate extension
Christos Tsantilas [Tue, 14 Jun 2016 15:56:12 +0000 (18:56 +0300)] 
TLS Authority Key Identifier certificate extension

This patch add support for mimicking TLS Authority Key Identifier certificate
extension in Squid generated TLS certificates: If the origin server certificate
has that extension, the generated certificate (via the ssl_crtd daemon or
internally) should have the same extension, with the same set of fields if
possible.

This is a Measurement Factory project

9 years agoAdded a script to find kid-specific cache.log lines.
Alex Rousskov [Tue, 14 Jun 2016 15:20:59 +0000 (09:20 -0600)] 
Added a script to find kid-specific cache.log lines.

9 years agoCleanup cppunit detection and use
Amos Jeffries [Tue, 14 Jun 2016 06:22:55 +0000 (18:22 +1200)] 
Cleanup cppunit detection and use

The cppunit-config tool has apparently been replaced by pkg-config .pc
file years ago and is now in the process of being removed from some OS.
Notably Fedora.

Which means our present way of detecting it for use by "make check" will
increasingly fail.

This converts configure.ac to using the pkg-config method of detection
and updates the --with-cppunit-basedir parameter to --without-cppunit
matching our naming and usage scheme for other similar options. If a
=PATH is explicitly provided cppunit is assumed to exist at that
location without configure-time checking.

9 years agoDestructed objects that were never born are not alive.
Alex Rousskov [Mon, 13 Jun 2016 23:25:45 +0000 (17:25 -0600)] 
Destructed objects that were never born are not alive.

Such objects are typical in partial logs that are missing some
construction events.

9 years agoBug 4291: workaround DeferredReadManager::popHead segfault during shutdown
Lubos Uhliarik [Mon, 13 Jun 2016 12:50:25 +0000 (00:50 +1200)] 
Bug 4291: workaround DeferredReadManager::popHead segfault during shutdown

9 years agoUpdate cppunit detection
Amos Jeffries [Mon, 13 Jun 2016 07:46:59 +0000 (19:46 +1200)] 
Update cppunit detection

9 years agoFix for valgrind-discovered trunk errors.
Eduard Bagdasaryan [Sun, 12 Jun 2016 07:44:36 +0000 (19:44 +1200)] 
Fix for valgrind-discovered trunk errors.

During start-up, Valgrind reported many errors with a similar
message: "Use of uninitialised value of size 8...". These errors
were caused by HttpRequestMethod& parameter during private
key generation: it was used as a raw void* memory there. HttpRequestMethod
is a non-POD type and has some "padding" bytes, which are not initialized
by the constructor.

The patch simplifies private key generation by using a simple counter for this,
which is sufficient to create a unique key within a single Squid process.
Except fixing Valgrind errors, this solution saves many CPU cycles wasted on
generating MD5 hashes just to "guarantee" uniqueness within a single process.

9 years agoFix GCC 4.8 eCAP builds after rev.14701
Amos Jeffries [Sat, 11 Jun 2016 05:28:18 +0000 (17:28 +1200)] 
Fix GCC 4.8 eCAP builds after rev.14701

It seems GCC 4.8 at least does not reorder lnker flags so we can't use
the particular LDADD approach there. Use explicit setting of LIBS and
CXXFLAGS instead.

9 years agoFix SEGFAULT parsing malformed adaptation service configuration
Amos Jeffries [Fri, 10 Jun 2016 09:09:57 +0000 (21:09 +1200)] 
Fix SEGFAULT parsing malformed adaptation service configuration

icap_service or ecap_service directives with missing field values need to
abort cleanly with an error.

Also, fix config parsing error messages in adaptation service parse to
use "ERROR:" prefix consistent with squid.conf general behaviour.

9 years agoBug 4446: undefined reference to 'libecap::Name::Name'
Amos Jeffries [Fri, 10 Jun 2016 04:53:56 +0000 (16:53 +1200)] 
Bug 4446: undefined reference to 'libecap::Name::Name'

Add autoconf link check for -lecap if it is going to be used.

Also, cleanup adaptation dependency situation. Automake *_DEPENDENCIES should
no longer be used and there is no need for both AC_SUBST component lists and
ENABLE_FOO conditionals to be defined. This allows simpler configure.ac logic
for both eCAP and ICAP.

9 years agoFix shell issues with require_smblib definition in rev.14692
Amos Jeffries [Fri, 10 Jun 2016 02:36:42 +0000 (14:36 +1200)] 
Fix shell issues with require_smblib definition in rev.14692

Some shells do not handle sub-shell expansion in a way suitable for bare
inclusion into if statements as needed by AM_CONDITIONAL.

9 years ago4.0.11 SQUID_4_0_11
Amos Jeffries [Thu, 9 Jun 2016 20:31:15 +0000 (08:31 +1200)] 
4.0.11

9 years agoAdd missing stub definition after rev.14696
Amos Jeffries [Mon, 6 Jun 2016 11:02:59 +0000 (23:02 +1200)] 
Add missing stub definition after rev.14696

9 years agoDocs: fix typo in rev.14521
Amos Jeffries [Mon, 6 Jun 2016 03:28:37 +0000 (15:28 +1200)] 
Docs: fix typo in rev.14521

9 years agoCryptoNG: cleanup TLS/SSL context initialization sequence
Amos Jeffries [Thu, 2 Jun 2016 09:52:43 +0000 (21:52 +1200)] 
CryptoNG: cleanup TLS/SSL context initialization sequence

The libsecurity ServerOptions and PeerOptions class methods are now
supposed to be the API for creating SSL contexts for https_port,
cache_peer and outgoing connections.

Continue the API transition by making the callers of sslCreate*Context()
functions use the libsecurity API instead and repurpose the now obsolete
functions into the Ssl:: namespace to initialize the keying material and
other not-yet-converted OpenSSL state details of an existing context.

A side effect of this is that GnuTLS contexts are now actually created
and initialized as far as they can be.

SSL-Bump context initialization is not altered by this.

9 years agoMark refresh-waiting transactions with REFRESH.
Eduard Bagdasaryan [Thu, 2 Jun 2016 09:49:19 +0000 (21:49 +1200)] 
Mark refresh-waiting transactions with REFRESH.

Before this change, transactions initiating a refresh were still marked
as TCP_HIT*. If such a transaction was terminated (for any reason)
before receiving an IMS reply, it was logged with that misleading tag.
Now, such transactions are logged using TCP_REFRESH[_ABORTED].

After the refresh (successful or otherwise), the tag changes to one of
the other TCP_REFRESH_* values, as before.

9 years agoFix shell substitution typo in rev.14693
Amos Jeffries [Wed, 1 Jun 2016 11:09:57 +0000 (23:09 +1200)] 
Fix shell substitution typo in rev.14693

9 years agoCleanup: improve automake coding guideline adherence
Amos Jeffries [Tue, 31 May 2016 22:47:03 +0000 (10:47 +1200)] 
Cleanup: improve automake coding guideline adherence

Several features were not following guidelines on ENABLE_* automake
variable naming.

As a result fix ESI unit tests which were not being run and simplify
adaptation conditional creation.

And remove unused HAVE_SPEGNO conditional.

9 years agoDeprecating SMB LanMan helpers
Amos Jeffries [Mon, 30 May 2016 01:55:32 +0000 (13:55 +1200)] 
Deprecating SMB LanMan helpers

Bring the SMB LanMan helpers one step closer to removal by dropping them
from the set of helpers which are auto-detected and built by default
with Squid.

They are still available for the minority using them. But need to be
explicitly listed in the ./configure options to be built.

9 years agoRemove unused var after r14689
Christos Tsantilas [Sat, 28 May 2016 07:46:14 +0000 (10:46 +0300)] 
Remove unused var after r14689

9 years agoSourceFormat Enforcement
Source Maintenance [Fri, 27 May 2016 18:12:12 +0000 (18:12 +0000)] 
SourceFormat Enforcement

9 years agoRemove ie_refresh configuration option
Amos Jeffries [Fri, 27 May 2016 12:58:15 +0000 (00:58 +1200)] 
Remove ie_refresh configuration option

This option was provided as a hack to workaround problems in MSIE 5.01
and older.

Since those MSIE versions are long deprecated and no longer even
registering on the popularity charts for more than 5 years I think its
time we removed this hack.

9 years agoReplace new/delete operators using modern C++ rules.
Alex Rousskov [Fri, 27 May 2016 12:46:02 +0000 (00:46 +1200)] 
Replace new/delete operators using modern C++ rules.

This change was motivated by "Mismatched free()/delete/delete[]" errors
reported by valgrind and mused about in Squid source code.

I speculate that the old new/delete replacement code was the result of
slow accumulation of working hacks to accomodate various environments,
as compiler support for the feature evolved. The cumulative result does
not actually work well (see the above paragraph), and the replacement
functions had the following visible coding problems according to [1,2]:

a) Declared with non-standard profiles that included throw specifiers.
b) Declared inline. C++ says that the results of inline declarations
   have unspecified effects. In Squid, they probably necessitated
   complex compiler-specific "extern inline" workarounds.
c) Defined in the header file. C++ says that defining replacements "in
   any source file" is enough and that multiple replacements per
   program (which is what a header file definition produces) result in
   "undefined behavior".
d) Declared inconsistently (only 2 out of 4 flavors). Declaring one base
   flavor should be sufficient, but if we declare more, we should
   declare all of them.

[1] http://en.cppreference.com/w/cpp/memory/new/operator_new
[2] http://en.cppreference.com/w/cpp/memory/new/operator_delete

The replacements were not provided to clang (trunk r13219), but there
was no explanation why. This patch does not change that exclusion.

I have no idea whether any of the old hacks are still necessary in some
cases. However, I suspect that either we do not care much if the
replacements are not enabled on some poorly supported platforms OR we
can disable them (or make them work) using much simpler hacks for the
platforms we do care about.

9 years agoMerge from trunk rev.14687
Amos Jeffries [Thu, 26 May 2016 14:48:59 +0000 (02:48 +1200)] 
Merge from trunk rev.14687

9 years agoBug 4517 error: comparison between signed and unsigned integer
Alex Rousskov [Mon, 23 May 2016 23:20:27 +0000 (17:20 -0600)] 
Bug 4517 error: comparison between signed and unsigned integer

The old cast is required when size_t is unsigned (as it should be).
The new cast is required when size_t is signed (as it may be).

We could cast just the left-hand side to be signed instead, but it feels
slightly wrong to do that here because all values we are casting are
meant to be unsigned and, hence, in theory, might overflow in some
future version of the code if we cast them to a signed value now and
forget to fix that cast later while adding support for larger values.

9 years agoBug 4485: off-by-one out-of-bounds Parser::Tokenizer::int64() read errors
Eduard Bagdasaryan [Mon, 23 May 2016 12:35:06 +0000 (00:35 +1200)] 
Bug 4485: off-by-one out-of-bounds Parser::Tokenizer::int64() read errors

9 years agoFixed build-breaking typo in r14684.
Alex Rousskov [Sat, 21 May 2016 23:19:36 +0000 (17:19 -0600)] 
Fixed build-breaking typo in r14684.

9 years agoGnuTLS: Simplify trusted CA loading
Amos Jeffries [Sat, 21 May 2016 21:30:25 +0000 (09:30 +1200)] 
GnuTLS: Simplify trusted CA loading

9 years agoDo not override user defined -std option
Amos Jeffries [Sat, 21 May 2016 12:12:51 +0000 (00:12 +1200)] 
Do not override user defined -std option

9 years agoFixed icons loading speed.
Alex Rousskov [Fri, 20 May 2016 18:16:19 +0000 (12:16 -0600)] 
Fixed icons loading speed.

Since trunk r14100 (Bug 3875: bad mimeLoadIconFile error handling), each
icon was read from disk and written to Store one character at a time. I
did not measure startup delays in production, but in debugging runs,
fixing this bug sped up icons loading from 1 minute to 4 seconds.

9 years agoNever enable OPENSSL_HELLO_OVERWRITE_HACK automatically.
Alex Rousskov [Fri, 20 May 2016 17:19:44 +0000 (11:19 -0600)] 
Never enable OPENSSL_HELLO_OVERWRITE_HACK automatically.

OPENSSL_HELLO_OVERWRITE_HACK, a.k.a adjustSSL(), a.k.a. "splice after
stare and bump after peek" hack requires updating internal/private
OpenSSL structures. The hack also relies on SSL client making SSL
negotiation decisions that are similar to our OpenSSL version decisions.
Squid used to enable this hack if it could compile the sources, but:

* The hack works well in fewer and fewer cases.
* Making its behavior reliable is virtually impossible.
* Maintaining this hack is increasingly difficult, especially after
  OpenSSL has changed its internal structures in v1.1.
* The combination of other bugs (fixed in r14670) and TLS extensions in
  popular browsers effectively disabled this hack for a while, and
  nobody (that we know of) noticed.

This temporary change disables the hack even if it can be compiled. If
an admin is willing to take the risks, they may enable it manually by
setting SQUID_USE_OPENSSL_HELLO_OVERWRITE_HACK macro value to 1 during
the build.

If, after this experimental change, we get no complaints (that we can
address), the hack will be completely removed from Squid sources.

9 years agoCheck for SSL_CIPHER_get_id() support required in adjustSSL().
Alex Rousskov [Fri, 20 May 2016 16:49:07 +0000 (10:49 -0600)] 
Check for SSL_CIPHER_get_id() support required in adjustSSL().

Our adjustSSL() hack requires SSL_CIPHER_get_id() since trunk r14670,
but that OpenSSL function is not available in some environments, leading
to compilation failures.

9 years agoFix OpenSSL detection on FreeBSD
Amos Jeffries [Fri, 20 May 2016 14:57:48 +0000 (02:57 +1200)] 
Fix OpenSSL detection on FreeBSD

9 years agoDo not allow low-level debugging to hide important/critical messages.
Alex Rousskov [Fri, 20 May 2016 13:20:27 +0000 (01:20 +1200)] 
Do not allow low-level debugging to hide important/critical messages.

Removed debugs() side effects that inadvertently resulted in some
important/critical messages logged at the wrong debugging level and,
hence, becoming invisible to the admin. The removed side effects set the
"current" debugging level when a debugs() parameter called a function
that also called debugs(). The last nested debugs() called affected the
level of all debugs() still in progress!

Related changes:

* Reentrant debugging messages no longer clobber parent messages. Each
  debugging message is logged separately, in the natural order of
  debugs() calls that would have happened if debugs() were a function
  (that gets already evaluated arguments) and not a macro (that
  evaluates its arguments in the middle of the call). This order is
  "natural" because good macros work like functions from the caller
  point of view.

* Assertions hit while evaluating debugs() parameters are now logged
  instead of being lost with the being-built debugs() log line.

* 10-20% faster debugs() performance because we no longer allocate a new
  std::ostringstream buffer for the vast majority of debugs() calls.
  Only reentrant calls get a new buffer.

* Removed old_debug(), addressing an old "needs to die" to-do.

* Removed do_debug() that changed debugging level while testing whether
  debugging is needed. Use side-effect-free Debug::Enabled() instead.

Also removed the OutStream wrapper class. The wrapper was added in trunk
revision 13767 that promised to (but did not?) MemPool the debug output
buffers. We no longer "new" the buffer stream so a custom new() method
would be unused. Besides, the r13767 explanation implied that providing
a Child::new() method would somehow overwrite Parent::allocator_type,
which did not compute for me. Finally, Squid "new"s other allocator-
enabled STL objects without overriding their new methods so either the
same problem is still there or it did not exist (or was different?).

Also removed Debug::xassert() because the debugs() assertions now work
OK without that hack.

9 years agoHTTP/1.1: unfold mime header blocks
Amos Jeffries [Fri, 20 May 2016 08:28:33 +0000 (20:28 +1200)] 
HTTP/1.1: unfold mime header blocks

Enact the RFC 7230 section 3 requirement that proxies remove obs-fold from
received mime header blocks and drop all lines that start with whitespace
immediately following the request-line.

Also;

* Shuffle the DelimiterCharacters() and RelaxedDelimiters() helper methods
  to Http::One::Parser for use in processing mime.

* Extend the headersEnd() function with a wrapper to avoid SBuf::c_str()
  and to efficiently report whether obs-fold exists without needing to
  re-scan the block.

* Document the mime_header.h API function(s).

* Add Http::One::CrLf() to present a SBuf CRLF constant. This can be used
  instead of the many local string definitions we have now.
  The implementation could perhapse be done better for performance, but not
  done here.