]> git.kaiwu.me - nginx.git/log
nginx.git
11 years agonginx-1.8.0-RELEASE release-1.8.0
Maxim Dounin [Tue, 21 Apr 2015 14:11:58 +0000 (17:11 +0300)]
nginx-1.8.0-RELEASE

11 years agoCore: ensure that ngx_config.h is always included first.
Sergey Kandaurov [Thu, 16 Apr 2015 15:18:37 +0000 (18:18 +0300)]
Core: ensure that ngx_config.h is always included first.

This fixes compilation of various 3rd party modules when nginx is
configured with threads.

11 years agoStable branch.
Maxim Dounin [Thu, 16 Apr 2015 14:00:52 +0000 (17:00 +0300)]
Stable branch.

11 years agoFixed build, broken by 8b7f062a3fe6.
Ruslan Ermilov [Thu, 16 Apr 2015 12:05:40 +0000 (15:05 +0300)]
Fixed build, broken by 8b7f062a3fe6.

Casting a "const char *" to "char *" doesn't work on older gcc versions.

11 years agoCore: added OpenSSL version information to "nginx -V" output.
Vladimir Homutov [Thu, 16 Apr 2015 09:17:41 +0000 (12:17 +0300)]
Core: added OpenSSL version information to "nginx -V" output.

11 years agoVersion bump.
Vladimir Homutov [Thu, 16 Apr 2015 09:13:51 +0000 (12:13 +0300)]
Version bump.

11 years agorelease-1.7.12 tag
Maxim Dounin [Tue, 7 Apr 2015 15:35:33 +0000 (18:35 +0300)]
release-1.7.12 tag

11 years agonginx-1.7.12-RELEASE release-1.7.12
Maxim Dounin [Tue, 7 Apr 2015 15:35:33 +0000 (18:35 +0300)]
nginx-1.7.12-RELEASE

11 years agoCore: guard against spinlock usage without atomic ops.
Ruslan Ermilov [Thu, 26 Mar 2015 11:15:06 +0000 (14:15 +0300)]
Core: guard against spinlock usage without atomic ops.

The new thread pools code uses spinlocks.

11 years agoCore: limited levels of subdirectory hierarchy used for temp files.
Sergey Kandaurov [Mon, 6 Apr 2015 22:32:08 +0000 (01:32 +0300)]
Core: limited levels of subdirectory hierarchy used for temp files.

Similar to ngx_http_file_cache_set_slot(), the last component of file->name
with a fixed length of 10 bytes, as generated in ngx_create_temp_path(), is
used as a source for the names of intermediate subdirectories with each one
taking its own part.  Ensure that the sum of specified levels with slashes
fits into the length (ticket #731).

11 years agoCore: removed excessive initialization in ngx_conf_set_path_slot().
Sergey Kandaurov [Mon, 6 Apr 2015 22:32:07 +0000 (01:32 +0300)]
Core: removed excessive initialization in ngx_conf_set_path_slot().

Level hierarchy is pre-zeroed in ngx_pcalloc() of the surrounding ngx_path_t.

11 years agoCore: fixed error handling on ngx_conf_full_name() failure.
Sergey Kandaurov [Mon, 6 Apr 2015 22:32:05 +0000 (01:32 +0300)]
Core: fixed error handling on ngx_conf_full_name() failure.

11 years agoUpstream: abbreviated SSL handshake may interact badly with Nagle.
Ruslan Ermilov [Mon, 6 Apr 2015 21:07:04 +0000 (00:07 +0300)]
Upstream: abbreviated SSL handshake may interact badly with Nagle.

11 years agoRequest body: always flush buffers if request buffering is off.
Valentin Bartenev [Mon, 6 Apr 2015 16:20:36 +0000 (19:20 +0300)]
Request body: always flush buffers if request buffering is off.

This fixes unbuffered proxying to SSL backends, since it prevents
ngx_ssl_send_chain() from accumulation of request body in the SSL
buffer.

11 years agoUsed the correct type for the AIO preload handler return value.
Valentin Bartenev [Mon, 6 Apr 2015 08:22:24 +0000 (11:22 +0300)]
Used the correct type for the AIO preload handler return value.

11 years agoConfigure: style.
Maxim Dounin [Fri, 3 Apr 2015 15:20:57 +0000 (18:20 +0300)]
Configure: style.

11 years agoOCSP stapling: missing free calls.
Filipe da Silva [Wed, 1 Apr 2015 13:05:08 +0000 (15:05 +0200)]
OCSP stapling: missing free calls.

Missing call to X509_STORE_CTX_free when X509_STORE_CTX_init fails.
Missing call to OCSP_CERTID_free when OCSP_request_add0_id fails.
Possible leaks in vary particular scenariis of memory shortage.

11 years agoCache: added support for reading of the header in thread pools.
Valentin Bartenev [Wed, 1 Apr 2015 00:49:17 +0000 (03:49 +0300)]
Cache: added support for reading of the header in thread pools.

11 years agoFixed invalid access to complex value defined as an empty string.
Sergey Kandaurov [Tue, 31 Mar 2015 14:45:50 +0000 (17:45 +0300)]
Fixed invalid access to complex value defined as an empty string.

Found by Valgrind.

11 years agoEvents: fixed possible crash on start or reload.
Valentin Bartenev [Fri, 27 Mar 2015 18:19:20 +0000 (21:19 +0300)]
Events: fixed possible crash on start or reload.

The main thread could wake up and start processing the notify event
before the handler was set.

11 years agoEvents: made posted events macros safe.
Valentin Bartenev [Fri, 27 Mar 2015 16:57:15 +0000 (19:57 +0300)]
Events: made posted events macros safe.

11 years agoSPDY: always push pending data.
Valentin Bartenev [Mon, 23 Mar 2015 18:04:13 +0000 (21:04 +0300)]
SPDY: always push pending data.

This helps to avoid suboptimal behavior when a client waits for a control
frame or more data to increase window size, but the frames have been delayed
in the socket buffer.

The delays can be caused by bad interaction between Nagle's algorithm on
nginx side and delayed ACK on the client side or by TCP_CORK/TCP_NOPUSH
if SPDY was working without SSL and sendfile() was used.

The pushing code is now very similar to ngx_http_set_keepalive().

11 years agoSPDY: fixed error handling in ngx_http_spdy_send_output_queue().
Valentin Bartenev [Mon, 23 Mar 2015 17:47:46 +0000 (20:47 +0300)]
SPDY: fixed error handling in ngx_http_spdy_send_output_queue().

11 years agoVersion bump.
Maxim Dounin [Thu, 26 Mar 2015 14:36:39 +0000 (17:36 +0300)]
Version bump.

11 years agoProxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin [Wed, 25 Mar 2015 23:31:30 +0000 (02:31 +0300)]
Proxy: fixed proxy_request_buffering and chunked with preread body.

If any preread body bytes were sent in the first chain, chunk size was
incorrectly added before the whole chain, including header, resulting in
an invalid request sent to upstream.  Fixed to properly add chunk size
after the header.

11 years agorelease-1.7.11 tag
Maxim Dounin [Tue, 24 Mar 2015 15:45:34 +0000 (18:45 +0300)]
release-1.7.11 tag

11 years agonginx-1.7.11-RELEASE release-1.7.11
Maxim Dounin [Tue, 24 Mar 2015 15:45:34 +0000 (18:45 +0300)]
nginx-1.7.11-RELEASE

11 years agoUpstream: uwsgi_request_buffering, scgi_request_buffering.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
Upstream: uwsgi_request_buffering, scgi_request_buffering.

11 years agoFastCGI: fastcgi_request_buffering.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
FastCGI: fastcgi_request_buffering.

11 years agoProxy: proxy_request_buffering chunked support.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
Proxy: proxy_request_buffering chunked support.

11 years agoRequest body: unbuffered reading.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
Request body: unbuffered reading.

The r->request_body_no_buffering flag was introduced.  It instructs
client request body reading code to avoid reading the whole body, and
to call post_handler early instead.  The caller should use the
ngx_http_read_unbuffered_request_body() function to read remaining
parts of the body.

Upstream module is now able to use this mode, if configured with
the proxy_request_buffering directive.

11 years agoRequest body: filters support.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
Request body: filters support.

11 years agoRequest body: moved request body writing to save filter.
Maxim Dounin [Mon, 23 Mar 2015 18:09:19 +0000 (21:09 +0300)]
Request body: moved request body writing to save filter.

11 years agoRequest body: free chain links in ngx_http_write_request_body().
Maxim Dounin [Mon, 23 Mar 2015 18:09:12 +0000 (21:09 +0300)]
Request body: free chain links in ngx_http_write_request_body().

11 years agoOutput chain: free chain links in ngx_chain_writer().
Maxim Dounin [Mon, 23 Mar 2015 18:09:05 +0000 (21:09 +0300)]
Output chain: free chain links in ngx_chain_writer().

11 years agoOutput chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin [Mon, 23 Mar 2015 17:56:58 +0000 (20:56 +0300)]
Output chain: zero size buf alerts in ngx_chain_writer().

Now we log a "zero size buf in chain writer" alert if we encounter a zero
sized buffer in ngx_chain_writer(), and skip the buffer.

11 years agoFormat specifier fixed for file size of buffers.
Maxim Dounin [Mon, 23 Mar 2015 16:28:54 +0000 (19:28 +0300)]
Format specifier fixed for file size of buffers.

11 years agoProxy: fixed proxy_set_body with proxy_cache.
Maxim Dounin [Mon, 23 Mar 2015 16:28:54 +0000 (19:28 +0300)]
Proxy: fixed proxy_set_body with proxy_cache.

If the last header evaluation resulted in an empty header, the e.skip flag
was set and was not reset when we've switched to evaluation of body_values.
This incorrectly resulted in body values being skipped instead of producing
some correct body as set by proxy_set_body.  Fix is to properly reset
the e.skip flag.

As the problem only appeared if the last potentially non-empty header
happened to be empty, it only manifested itself if proxy_set_body was used
with proxy_cache.

11 years agoThread pools: implemented graceful exiting of threads.
Valentin Bartenev [Mon, 23 Mar 2015 14:51:21 +0000 (17:51 +0300)]
Thread pools: implemented graceful exiting of threads.

11 years agoThread pools: removed unused pointer to memory pool.
Valentin Bartenev [Mon, 23 Mar 2015 14:51:21 +0000 (17:51 +0300)]
Thread pools: removed unused pointer to memory pool.

No functional changes.

11 years agoThread pools: keep waiting tasks mutex in ngx_thread_pool_t.
Valentin Bartenev [Mon, 23 Mar 2015 14:51:21 +0000 (17:51 +0300)]
Thread pools: keep waiting tasks mutex in ngx_thread_pool_t.

It's not needed for completed tasks queue since the previous change.

No functional changes.

11 years agoThread pools: replaced completed tasks queue mutex with spinlock.
Valentin Bartenev [Mon, 23 Mar 2015 14:51:21 +0000 (17:51 +0300)]
Thread pools: replaced completed tasks queue mutex with spinlock.

11 years agoRemoved stub implementation of win32 mutexes.
Ruslan Ermilov [Mon, 23 Mar 2015 10:52:47 +0000 (13:52 +0300)]
Removed stub implementation of win32 mutexes.

11 years agoUpdated OpenSSL used for win32 builds.
Maxim Dounin [Sun, 22 Mar 2015 23:44:41 +0000 (02:44 +0300)]
Updated OpenSSL used for win32 builds.

11 years agoSSL: use of SSL_MODE_NO_AUTO_CHAIN.
Maxim Dounin [Sun, 22 Mar 2015 23:42:35 +0000 (02:42 +0300)]
SSL: use of SSL_MODE_NO_AUTO_CHAIN.

The SSL_MODE_NO_AUTO_CHAIN mode prevents OpenSSL from automatically
building a certificate chain on the fly if there is no certificate chain
explicitly provided.  Before this change, certificates provided via the
ssl_client_certificate and ssl_trusted_certificate directives were
used by OpenSSL to automatically build certificate chains, resulting
in unexpected (and in some cases unneeded) chains being sent to clients.

11 years agoSSL: avoid SSL_CTX_set_tmp_rsa_callback() call with LibreSSL.
Maxim Dounin [Sun, 22 Mar 2015 23:42:34 +0000 (02:42 +0300)]
SSL: avoid SSL_CTX_set_tmp_rsa_callback() call with LibreSSL.

LibreSSL removed support for export ciphers and a call to
SSL_CTX_set_tmp_rsa_callback() results in an error left in the error
queue.  This caused alerts "ignoring stale global SSL error (...called
a function you should not call) while SSL handshaking" on a first connection
in each worker process.

11 years agoSSL: clear protocol options.
Maxim Dounin [Sun, 22 Mar 2015 23:42:32 +0000 (02:42 +0300)]
SSL: clear protocol options.

LibreSSL 2.1.1+ started to set SSL_OP_NO_SSLv3 option by default on
new contexts.  This makes sure to clear it to make it possible to use SSLv3
with LibreSSL if enabled in nginx config.

Prodded by Kuramoto Eiji.

11 years agoCore: added cyclic memory buffer support for error_log.
Valentin Bartenev [Thu, 19 Mar 2015 16:29:43 +0000 (19:29 +0300)]
Core: added cyclic memory buffer support for error_log.

Example of usage:

  error_log memory:16m debug;

This allows to configure debug logging with minimum impact on performance.
It's especially useful when rare crashes are experienced under high load.

The log can be extracted from a coredump using the following gdb script:

  set $log = ngx_cycle->log

  while $log->writer != ngx_log_memory_writer
      set $log = $log->next
  end

  set $buf = (ngx_log_memory_buf_t *) $log->wdata
  dump binary memory debug_log.txt $buf->start $buf->end

11 years agoRemoved busy locks.
Ruslan Ermilov [Fri, 20 Mar 2015 03:45:32 +0000 (06:45 +0300)]
Removed busy locks.

11 years agoRemoved ngx_connection_t.lock.
Ruslan Ermilov [Fri, 20 Mar 2015 03:43:19 +0000 (06:43 +0300)]
Removed ngx_connection_t.lock.

11 years agoRemoved unix ngx_threaded and related ngx_process_changes.
Ruslan Ermilov [Fri, 20 Mar 2015 03:43:19 +0000 (06:43 +0300)]
Removed unix ngx_threaded and related ngx_process_changes.

11 years agoRemoved old pthread implementation.
Ruslan Ermilov [Fri, 20 Mar 2015 03:43:19 +0000 (06:43 +0300)]
Removed old pthread implementation.

11 years agoRemoved old FreeBSD rfork() thread implementation.
Ruslan Ermilov [Fri, 20 Mar 2015 03:43:19 +0000 (06:43 +0300)]
Removed old FreeBSD rfork() thread implementation.

11 years agoThread pools: silence warning on process exit.
Ruslan Ermilov [Thu, 19 Mar 2015 20:20:18 +0000 (23:20 +0300)]
Thread pools: silence warning on process exit.

Work around pthread_cond_destroy() and pthread_mutex_destroy() returning
EBUSY.  A proper solution would be to ensure all threads are terminated.

11 years agoThread pools: fixed the waiting tasks accounting.
Ruslan Ermilov [Thu, 19 Mar 2015 10:00:48 +0000 (13:00 +0300)]
Thread pools: fixed the waiting tasks accounting.

Behave like POSIX semaphores.  If N worker threads are waiting for tasks,
at least that number of tasks should be allowed to be put into the queue.

11 years agoThread pools: keep waiting tasks counter in ngx_thread_pool_t.
Ruslan Ermilov [Thu, 19 Mar 2015 20:19:35 +0000 (23:19 +0300)]
Thread pools: keep waiting tasks counter in ngx_thread_pool_t.

It's not needed for completed tasks queue.

No functional changes.

11 years agoSPDY: fixed format specifier in logging.
Xiaochen Wang [Sun, 15 Mar 2015 13:46:21 +0000 (21:46 +0800)]
SPDY: fixed format specifier in logging.

11 years agoAdded support for offloading Linux sendfile() in thread pools.
Valentin Bartenev [Sat, 14 Mar 2015 14:37:30 +0000 (17:37 +0300)]
Added support for offloading Linux sendfile() in thread pools.

11 years agoAdded support for offloading read() in thread pools.
Valentin Bartenev [Sat, 14 Mar 2015 14:37:25 +0000 (17:37 +0300)]
Added support for offloading read() in thread pools.

11 years agoEvents: implemented eventport notification mechanism.
Ruslan Ermilov [Sat, 14 Mar 2015 14:37:21 +0000 (17:37 +0300)]
Events: implemented eventport notification mechanism.

11 years agoEvents: implemented kqueue notification mechanism.
Valentin Bartenev [Sat, 14 Mar 2015 14:37:16 +0000 (17:37 +0300)]
Events: implemented kqueue notification mechanism.

11 years agoEvents: implemented epoll notification mechanism.
Valentin Bartenev [Sat, 14 Mar 2015 14:37:13 +0000 (17:37 +0300)]
Events: implemented epoll notification mechanism.

11 years agoThread pools implementation.
Valentin Bartenev [Sat, 14 Mar 2015 14:37:07 +0000 (17:37 +0300)]
Thread pools implementation.

11 years agoConfigure: removed obsolete threads bits.
Ruslan Ermilov [Fri, 13 Mar 2015 16:08:27 +0000 (19:08 +0300)]
Configure: removed obsolete threads bits.

11 years agoRenamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.
Ruslan Ermilov [Wed, 4 Mar 2015 15:26:25 +0000 (18:26 +0300)]
Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.

It's mostly dead code and the original idea of worker threads has been rejected.

11 years agoConfigure: fixed type max value detection.
Ruslan Ermilov [Tue, 17 Mar 2015 23:04:39 +0000 (02:04 +0300)]
Configure: fixed type max value detection.

The code tried to use suffixes for "long" and "long long" types, but
it never worked as intended due to the bug in the shell code.  Also,
the max value for any 64-bit type other than "long long" on platforms
with 32-bit "long" would be incorrect if the bug was fixed.

So instead of fixing the bug in the shell code, always use the "int"
constant for 32-bit types, and "long long" constant for 64-bit types.

11 years agoOverflow detection in ngx_http_parse_chunked().
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:27 +0000 (00:26 +0300)]
Overflow detection in ngx_http_parse_chunked().

11 years agoOverflow detection in ngx_http_range_parse().
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:24 +0000 (00:26 +0300)]
Overflow detection in ngx_http_range_parse().

11 years agoOverflow detection in ngx_inet_addr().
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:22 +0000 (00:26 +0300)]
Overflow detection in ngx_inet_addr().

11 years agoCore: overflow detection in ngx_parse_time() (ticket #732).
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:20 +0000 (00:26 +0300)]
Core: overflow detection in ngx_parse_time() (ticket #732).

11 years agoRefactored ngx_parse_time().
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:18 +0000 (00:26 +0300)]
Refactored ngx_parse_time().

No functional changes.

11 years agoCore: overflow detection in number parsing functions.
Ruslan Ermilov [Mon, 16 Mar 2015 21:26:15 +0000 (00:26 +0300)]
Core: overflow detection in number parsing functions.

11 years agoCore: expose maximum values of time_t and ngx_int_t.
Ruslan Ermilov [Mon, 16 Mar 2015 21:24:34 +0000 (00:24 +0300)]
Core: expose maximum values of time_t and ngx_int_t.

These are needed to detect overflows.

11 years agoConfigure: removed redundant auto/have call.
Ruslan Ermilov [Fri, 13 Mar 2015 13:43:01 +0000 (16:43 +0300)]
Configure: removed redundant auto/have call.

The auto/feature call above is enough to set NGX_HAVE_SENDFILE.

11 years agoThe "aio" directive parser made smarter.
Ruslan Ermilov [Fri, 13 Mar 2015 13:42:52 +0000 (16:42 +0300)]
The "aio" directive parser made smarter.

It now prints meaningful warnings on all platforms.

No functional changes.

11 years agoEvents: fixed typo in the error message.
Ruslan Ermilov [Thu, 12 Mar 2015 20:03:03 +0000 (23:03 +0300)]
Events: fixed typo in the error message.

11 years agoDeprecated "aio sendfile".
Ruslan Ermilov [Thu, 12 Mar 2015 17:06:04 +0000 (20:06 +0300)]
Deprecated "aio sendfile".

Specifying "sendfile on" along with "aio on" activates the
aio pre-loading mode for sendfile().

11 years agoProxy: use an appropriate error on memory allocation failure.
Ruslan Ermilov [Wed, 4 Mar 2015 05:12:53 +0000 (08:12 +0300)]
Proxy: use an appropriate error on memory allocation failure.

11 years agoStyle: moved ngx_http_ephemeral() macro to ngx_http_request.h.
Ruslan Ermilov [Wed, 4 Mar 2015 05:10:40 +0000 (08:10 +0300)]
Style: moved ngx_http_ephemeral() macro to ngx_http_request.h.

11 years agoStyle: use %*s format, as in 68d21fd1dc64.
Ruslan Ermilov [Wed, 4 Mar 2015 05:05:38 +0000 (08:05 +0300)]
Style: use %*s format, as in 68d21fd1dc64.

11 years agoLog: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev [Wed, 4 Mar 2015 16:20:30 +0000 (19:20 +0300)]
Log: use ngx_cpymem() in a couple of places, no functional changes.

11 years agoUpstream keepalive: drop ready flag on EAGAIN from recv(MSG_PEEK).
Valentin Bartenev [Tue, 3 Mar 2015 14:48:57 +0000 (17:48 +0300)]
Upstream keepalive: drop ready flag on EAGAIN from recv(MSG_PEEK).

Keeping the ready flag in this case might results in missing notification of
broken connection until nginx tried to use it again.

While there, stale comment about stale event was removed since this function
is also can be called directly.

11 years agoEvents: simplified ngx_event_aio_t definition.
Ruslan Ermilov [Tue, 3 Mar 2015 15:09:13 +0000 (18:09 +0300)]
Events: simplified ngx_event_aio_t definition.

No functional changes.

11 years agoRefactored ngx_linux_sendfile_chain() even more.
Valentin Bartenev [Fri, 27 Feb 2015 16:19:08 +0000 (19:19 +0300)]
Refactored ngx_linux_sendfile_chain() even more.

The code that calls sendfile() was cut into a separate function.
This simplifies EINTR processing, yet is needed for the following
changes that add threads support.

11 years agoStyle.
Maxim Dounin [Mon, 2 Mar 2015 22:15:21 +0000 (01:15 +0300)]
Style.

Noted by Ruslan Ermilov.

11 years agoUpstream: upstream argument in ngx_http_upstream_process_request().
Maxim Dounin [Mon, 2 Mar 2015 18:44:42 +0000 (21:44 +0300)]
Upstream: upstream argument in ngx_http_upstream_process_request().

In case of filter finalization, r->upstream might be changed during
the ngx_event_pipe() call.  Added an argument to preserve it while
calling the ngx_http_upstream_process_request() function.

11 years agoUpstream: avoid duplicate finalization.
Maxim Dounin [Mon, 2 Mar 2015 18:44:32 +0000 (21:44 +0300)]
Upstream: avoid duplicate finalization.

A request may be already finalized when ngx_http_upstream_finalize_request()
is called, due to filter finalization: after filter finalization upstream
can be finalized via ngx_http_upstream_cleanup(), either from
ngx_http_terminate_request(), or because a new request was initiated
to an upstream.  Then the upstream code will see an error returned from
the filter chain and will call the ngx_http_upstream_finalize_request()
function again.

To prevent corruption of various upstream data in this situation, make sure
to do nothing but merely call ngx_http_finalize_request().

Prodded by Yichun Zhang, for details see the thread at
http://nginx.org/pipermail/nginx-devel/2015-February/006539.html.

11 years agoSSL: reset ready flag if recv(MSG_PEEK) found no bytes in socket.
Roman Arutyunyan [Mon, 2 Mar 2015 18:15:46 +0000 (21:15 +0300)]
SSL: reset ready flag if recv(MSG_PEEK) found no bytes in socket.

Previously, connection hung after calling ngx_http_ssl_handshake() with
rev->ready set and no bytes in socket to read.  It's possible in at least the
following cases:

 - when processing a connection with expired TCP_DEFER_ACCEPT on Linux
 - after parsing PROXY protocol header if it arrived in a separate TCP packet

Thanks to James Hamlin.

11 years agoCache: do not inherit last_modified and etag from stale response.
Roman Arutyunyan [Mon, 2 Mar 2015 16:47:13 +0000 (19:47 +0300)]
Cache: do not inherit last_modified and etag from stale response.

When replacing a stale cache entry, its last_modified and etag could be
inherited from the old entry if the response code is not 200 or 206.  Moreover,
etag could be inherited with any response code if it's missing in the new
response.  As a result, the cache entry is left with invalid last_modified or
etag which could lead to broken revalidation.

For example, when a file is deleted from backend, its last_modified is copied to
the new 404 cache entry and is used later for revalidation.  Once the old file
appears again with its original timestamp, revalidation succeeds and the cached
404 response is sent to client instead of the file.

The problem appeared with etags in 44b9ab7752e3 (1.7.3) and affected
last_modified in 1573fc7875fa (1.7.9).

11 years agoUpstream hash: speedup consistent hash init.
Roman Arutyunyan [Mon, 2 Mar 2015 15:41:29 +0000 (18:41 +0300)]
Upstream hash: speedup consistent hash init.

Repeatedly calling ngx_http_upstream_add_chash_point() to create
the points array in sorted order, is O(n^2) to the total weight.
This can cause nginx startup and reconfigure to be substantially
delayed.  For example, when total weight is 1000, startup takes
5s on a modern laptop.

Replace this with a linear insertion followed by QuickSort and
duplicates removal.  Startup for total weight of 1000 reduces to 40ms.

Based on a patch by Wai Keen Woon.

11 years agoMail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov [Fri, 27 Feb 2015 13:28:31 +0000 (16:28 +0300)]
Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.

Previously, the Auth-SSL-Verify header with the "NONE" value was always passed
to the auth_http script if verification of client certificates is disabled.

11 years agoMail: client SSL certificates support.
Maxim Dounin [Wed, 25 Feb 2015 14:48:05 +0000 (17:48 +0300)]
Mail: client SSL certificates support.

The "ssl_verify_client", "ssl_verify_depth", "ssl_client_certificate",
"ssl_trusted_certificate", and "ssl_crl" directives introduced to control
SSL client certificate verification in mail proxy module.

If there is a certificate, detail of the certificate are passed to
the auth_http script configured via Auth-SSL-Verify, Auth-SSL-Subject,
Auth-SSL-Issuer, Auth-SSL-Serial, Auth-SSL-Fingerprint headers.  If
the auth_http_pass_client_cert directive is set, client certificate
in PEM format will be passed in the Auth-SSL-Cert header (urlencoded).

If there is no required certificate provided during an SSL handshake
or certificate verification fails then a protocol-specific error is
returned after the SSL handshake and the connection is closed.

Based on previous work by Sven Peter, Franck Levionnois and Filipe Da Silva.

11 years agoMail: added Auth-SSL header to indicate SSL.
Maxim Dounin [Wed, 25 Feb 2015 14:47:49 +0000 (17:47 +0300)]
Mail: added Auth-SSL header to indicate SSL.

Based on a patch by Filipe da Silva.

11 years agoMail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.
Maxim Dounin [Wed, 25 Feb 2015 14:47:43 +0000 (17:47 +0300)]
Mail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.

There were no buffer overruns in real life as there is extra space
allocated for the Auth-Login-Attempt counter.

11 years agoSSL: account sent bytes in ngx_ssl_write().
Ruslan Ermilov [Tue, 24 Feb 2015 20:52:47 +0000 (23:52 +0300)]
SSL: account sent bytes in ngx_ssl_write().

11 years agoCore: fixed potential buffer overrun when initializing hash.
Maxim Dounin [Tue, 24 Feb 2015 15:37:14 +0000 (18:37 +0300)]
Core: fixed potential buffer overrun when initializing hash.

Initial size as calculated from the number of elements may be bigger
than max_size.  If this happens, make sure to set size to max_size.

Reported by Chris West.

11 years agoCache: reduced diffs to the plus version of nginx.
Ruslan Ermilov [Tue, 17 Feb 2015 13:27:52 +0000 (16:27 +0300)]
Cache: reduced diffs to the plus version of nginx.

No functional changes.

11 years agoCore: make ngx_connection_local_sockaddr() always assign address.
Roman Arutyunyan [Tue, 17 Feb 2015 11:26:44 +0000 (14:26 +0300)]
Core: make ngx_connection_local_sockaddr() always assign address.

Previously, this function checked for connection local address existence
and returned error if it was missing.  Now a new address is assigned in this
case making it possible to call this function not only for accepted connections.

11 years agoConfigure: typo fixed.
Sergey Kandaurov [Wed, 11 Feb 2015 17:18:55 +0000 (20:18 +0300)]
Configure: typo fixed.

11 years agoUnbreak building on FreeBSD without file AIO.
Valentin Bartenev [Wed, 11 Feb 2015 17:00:07 +0000 (20:00 +0300)]
Unbreak building on FreeBSD without file AIO.

It appeared that the NGX_HAVE_AIO_SENDFILE macro was defined regardless of
the "--with-file-aio" configure option and the NGX_HAVE_FILE_AIO macro.

Now they are related.

Additionally, fixed one macro.