Limit conn: returned to the old behavior of using the first actual limit on
the way.

It was unintentionally changed in r4272, so that it could only limit the first
location where the processing of the request has reached PREACCESS phase.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404459
Added ngx_ncpu detection for most *nix platforms.

This inaccurate detection by using sysconf(_SC_NPROCESSORS_ONLN) can improve
usage of the mutex lock optimization on multicore systems.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404460
Upstream: fixed "too big header" check.

If header filter postponed processing of a header by returning NGX_AGAIN
and not moved u->buffer->pos, previous check incorrectly assumed there
is additional space and did another recv() with zero-size buffer.  This
resulted in "upstream prematurely closed connection" error instead
of correct "upstream sent too big header" one.

Patch by Feibo Li.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404461
Proxy: renamed some "proxy_redirect" related declarations to a more general and
reusable.

No functional changes.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404462
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
separate function with trivial optimization.

No functional changes.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404463
Proxy: generic regex related code from the "proxy_redirect" directive moved
to a separate function.

No functional changes.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404464
Upstream: added callback hook for the "Set-Cookie" header.

No functional changes.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404465
Proxy: added the "proxy_cookie_domain" directive.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404466
Proxy: added the "proxy_cookie_path" directive.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404467
Removed r->cache/r->cached dependencies in range filter.

This is a layering violation, use correct offset calculations instead.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404468
Gzip filter: handling of empty flush buffers.

Empty flush buffers are legitimate and may happen e.g. due to $r->flush()
calls in embedded perl.  If there are no data buffered in zlib, deflate()
will return Z_BUF_ERROR (i.e. no progress possible) without adding anything
to output.  Don't treat Z_BUF_ERROR as fatal and correctly send empty flush
buffer if we have no data in output at all.

See this thread for details:
http://mailman.nginx.org/pipermail/nginx/2010-November/023693.html

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404469
Fix for proxy_store leaving temporary files for subrequests.

Temporary files might not be removed if the "proxy_store" or "fastcgi_store"
directives were used for subrequests (e.g. ssi includes) and client closed
connection prematurely.

Non-active subrequests are finalized out of the control of the upstream
module when client closes a connection.  As a result, the code to remove
unfinished temporary files in ngx_http_upstream_process_request() wasn't
executed.

Fix is to move relevant code into ngx_http_upstream_finalize_request() which
is called in all cases, either directly or via the cleanup handler.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404470
Variables: honor no_cacheable for not_found variables.

Variables with the "not_found" flag set follow the same rules as ones with
the "valid" flag set.  Make sure ngx_http_get_flushed_variable() will flush
non-cacheable variables with the "not_found" flag set.

This fixes at least one known problem with $args not available in a subrequest
(with args) when there were no args in the main request and $args variable was
queried in the main request (reported by Laurence Rowe aka elro on irc).

Also this eliminates unneeded call to ngx_http_get_indexed_variable() in
cacheable case (as it will return cached value anyway).

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404471
Core: protection from subrequest loops.

Without the protection, subrequest loop results in r->count overflow and
SIGSEGV.  Protection was broken in 0.7.25.

Note that this also limits number of parallel subrequests.  This
wasn't exactly the case before 0.7.25 as local subrequests were
completed directly.

See here for details:
http://nginx.org/pipermail/nginx-ru/2010-February/032184.html

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404472
Core: protection from cycles with named locations and post_action.

Now redirects to named locations are counted against normal uri changes
limit, and post_action respects this limit as well.  As a result at least
the following (bad) configurations no longer trigger infinite cycles:

1. Post action which recursively triggers post action:

    location / {
        post_action /index.html;
    }

2. Post action pointing to nonexistent named location:

    location / {
        post_action @nonexistent;
    }

3. Recursive error page for 500 (Internal Server Error) pointing to
   a nonexistent named location:

    location / {
        recursive_error_pages on;
        error_page 500 @nonexistent;
        return 500;
    }

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404473
Fixed build with embedded perl and --with-openssl.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404474
Time parsing cleanup.

Nuke NGX_PARSE_LARGE_TIME, it's not used since 0.6.30.  The only error
ngx_parse_time() can currently return is NGX_ERROR, check it explicitly
and make sure to cast it to appropriate type (either time_t or ngx_msec_t)
to avoid signedness warnings on platforms with unsigned time_t (notably QNX).

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404475
Added openat()/fstatat().

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404476
Changed ngx_open_and_stat_file() to use ngx_str_t.

No functional changes.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404477
Added disable_symlinks directive.

To completely disable symlinks (disable_symlinks on)
we use openat(O_NOFOLLOW) for each path component
to avoid races.

To allow symlinks with the same owner (disable_symlinks if_not_owner),
use openat() (followed by fstat()) and fstatat(AT_SYMLINK_NOFOLLOW),
and then compare uids between fstat() and fstatat().

As there is a race between openat() and fstatat() we don't
know if openat() in fact opened symlink or not.  Therefore,
we have to compare uids even if fstatat() reports the opened
component isn't a symlink (as we don't know whether it was
symlink during openat() or not).

Default value is off, i.e. symlinks are allowed.

--HG--
extra : convert_revision : svn%3Ac3fe7df1-7212-e011-8a91-001109144009/trunk%404478