summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
2013-07-25Event pipe: fixed writing cache header to a temp file.Maxim Dounin1-7/+4
With previous code the p->temp_file->offset wasn't adjusted if a temp file was written by the code in ngx_event_pipe_write_to_downstream() after an EOF, resulting in cache not being used with empty scgi and uwsgi responses with Content-Length set to 0. Fix it to call ngx_event_pipe_write_chain_to_temp_file() there instead of calling ngx_write_chain_to_temp_file() directly.
2013-07-11Core: extended ngx_sock_ntop() with socklen parameter.Vladimir Homutov3-3/+6
On Linux, sockaddr length is required to process unix socket addresses properly due to unnamed sockets (which don't have sun_path set at all) and abstract namespace sockets.
2013-05-31Win32: accept_mutex now always disabled (ticket #362).Maxim Dounin1-0/+11
Use of accept mutex on win32 may result in a deadlock if there are multiple worker_processes configured and the mutex is grabbed by a process which can't accept connections.
2013-05-31OCSP stapling: fixed incorrect debug level.Ruslan Ermilov1-1/+1
2013-05-21Style: replace SSL *ssl with ngx_ssl_conn_t *ssl_conn.Piotr Sikora2-2/+4
No functional changes. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-21Style: remove unnecessary references to HTTP from non-HTTP modules.Piotr Sikora1-3/+3
No functional changes. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-05-16OCSP stapling: fix error logging of successful OCSP responses.Piotr Sikora1-3/+2
Due to a bad argument list, nginx worker would crash (SIGSEGV) while trying to log the fact that it received OCSP response with "revoked" or "unknown" certificate status. While there, fix similar (but non-crashing) error a few lines above. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-04-16Events: backout eventport changes (r5172) for now.Maxim Dounin1-8/+0
Evenport method needs more work. Changes in r5172, while being correct, introduce various new regressions with current code.
2013-04-12Events: fixed typos in two previous commits.Valentin Bartenev2-2/+2
2013-04-12Events: handle only active events in eventport.Valentin Bartenev1-0/+8
We generate both read and write events if an error event was returned by port_getn() without POLLIN/POLLOUT, but we should not try to handle inactive events, they may even have no handler.
2013-04-12Events: protection from stale events in eventport and devpoll.Valentin Bartenev2-2/+8
Stale write event may happen if read and write events was reported both, and processing of the read event closed descriptor. In practice this might result in "sendfilev() failed (134: ..." or "writev() failed (134: ..." errors when switching to next upstream server. See report here: http://mailman.nginx.org/pipermail/nginx/2013-April/038421.html
2013-03-27Event connect: don't penalize AF_INET6 connections.Maxim Dounin1-1/+1
Problems with setsockopt(TCP_NODELAY) and setsockopt(TCP_NOPUSH), as well as sendfile() syscall on Solaris, are specific to UNIX-domain sockets. Other address families, i.e. AF_INET and AF_INET6, are fine.
2013-03-15Status: introduced the "ngx_stat_waiting" counter.Valentin Bartenev2-1/+6
And corresponding variable $connections_waiting was added. Previously, waiting connections were counted as the difference between active connections and the sum of reading and writing connections. That made it impossible to count more than one request in one connection as reading or writing (as is the case for SPDY). Also, we no longer count connections in handshake state as waiting.
2013-02-23SSL: retry "sess_id" and "id" allocations.Maxim Dounin1-2/+22
In case of fully populated SSL session cache with no memory left for new allocations, ngx_ssl_new_session() will try to expire the oldest non-expired session and retry, but only in case when slab allocation fails for "cached_sess", not when slab allocation fails for either "sess_id" or "id", which can happen for number of reasons and results in new session not being cached. Patch fixes this by adding retry logic to "sess_id" & "id" allocations. Patch by Piotr Sikora.
2013-02-01SSL: fixed ngx_ssl_handshake() with level-triggered event methods.Maxim Dounin1-0/+8
Missing calls to ngx_handle_write_event() and ngx_handle_read_event() resulted in a CPU hog during SSL handshake if an level-triggered event method (e.g. select) was used.
2013-01-28SSL: take into account data in the buffer while limiting output.Valentin Bartenev1-1/+1
In some rare cases this can result in a more smooth sending rate.
2013-01-28SSL: avoid calling SSL_write() with zero data size.Valentin Bartenev1-0/+6
According to documentation, calling SSL_write() with num=0 bytes to be sent results in undefined behavior. We don't currently call ngx_ssl_send_chain() with empty chain and buffer. This check handles the case of a chain with total data size that is a multiple of NGX_SSL_BUFSIZE, and with the special buffer at the end. In practice such cases resulted in premature connection close and critical error "SSL_write() failed (SSL:)" in the error log.
2013-01-28SSL: calculation of buffer size moved closer to its usage.Valentin Bartenev1-2/+2
No functional changes.
2013-01-28SSL: preservation of flush flag for buffered data.Valentin Bartenev1-5/+5
Previously, if SSL buffer was not sent we lost information that the data must be flushed.
2013-01-28SSL: resetting of flush flag after the data was written.Valentin Bartenev1-0/+2
There is no need to flush next chunk of data if it does not contain a buffer with the flush or last_buf flags set.
2013-01-28SSL: removed conditions that always hold true.Valentin Bartenev1-5/+3
2013-01-25Events: fixed null pointer dereference with resolver and poll.Ruslan Ermilov1-2/+2
A POLLERR signalled by poll() without POLLIN/POLLOUT, as seen on Linux, would generate both read and write events, but there's no write event handler for resolver events. A fix is to only call event handler of an active event.
2013-01-09SSL: speedup loading of configs with many ssl servers.Maxim Dounin1-2/+2
The patch saves one EC_KEY_generate_key() call per server{} block by informing OpenSSL about SSL_OP_SINGLE_ECDH_USE we are going to use before the SSL_CTX_set_tmp_ecdh() call. For a configuration file with 10k simple server{} blocks with SSL enabled this change reduces startup time from 18s to 5s on a slow test box here.
2013-01-08Events: added check for duplicate "events" directive.Valentin Bartenev1-0/+4
2012-10-30Event pipe: fixed handling of buf_to_file data.Maxim Dounin1-2/+9
Input filter might free a buffer if there is no data in it, and in case of first buffer (used for cache header and request header, aka p->buf_to_file) this resulted in cache corruption. Buffer memory was reused to read upstream response before headers were written to disk. Fix is to avoid moving pointers in ngx_event_pipe_add_free_buf() to a buffer start if we were asked to free a buffer used by p->buf_to_file. This fixes occasional cache file corruption, usually resulted in "cache file ... has md5 collision" alerts. Reported by Anatoli Marinov.
2012-10-03SSL: the "ssl_verify_client" directive parameter "optional_no_ca".Maxim Dounin1-0/+7
This parameter allows to don't require certificate to be signed by a trusted CA, e.g. if CA certificate isn't known in advance, like in WebID protocol. Note that it doesn't add any security unless the certificate is actually checked to be trusted by some external means (e.g. by a backend). Patch by Mike Kazantsev, Eric O'Connor.
2012-10-01OCSP stapling: build fixes.Maxim Dounin1-5/+5
With the "ssl_stapling_verify" commit build with old OpenSSL libraries was broken due to incorrect prototype of the ngx_ssl_stapling() function. One incorrect use of ngx_log_debug() instead of ngx_log_debug2() slipped in and broke win32 build.
2012-10-01OCSP stapling: ssl_stapling_verify directive.Maxim Dounin2-5/+10
OCSP response verification is now switched off by default to simplify configuration, and the ssl_stapling_verify allows to switch it on. Note that for stapling OCSP response verification isn't something required as it will be done by a client anyway. But doing verification on a server allows to mitigate some attack vectors, most notably stop an attacker from presenting some specially crafted data to all site clients.
2012-10-01OCSP stapling: OCSP_basic_verify() OCSP_TRUSTOTHER flag now used.Maxim Dounin1-1/+1
This is expected to simplify configuration in a common case when OCSP response is signed by a certificate already present in ssl_certificate chain. This case won't need any extra trusted certificates.
2012-10-01OCSP stapling: log error data in ngx_ssl_error().Maxim Dounin1-6/+17
It's hard to debug OCSP_basic_verify() failures without the actual error string it records in the error data field.
2012-10-01OCSP stapling: check Content-Type.Maxim Dounin1-0/+28
This will result in better error message in case of incorrect response from OCSP responder: ... OCSP responder sent invalid "Content-Type" header: "text/plain" while requesting certificate status, responder: ... vs. ... d2i_OCSP_RESPONSE() failed (SSL: error:0D07209B:asn1 encoding routines:ASN1_get_object:too long error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error) while requesting certificate status, responder: ...
2012-10-01OCSP stapling: loading OCSP responses.Maxim Dounin3-34/+1703
This includes the ssl_stapling_responder directive (defaults to OCSP responder set in certificate's AIA extension). OCSP response for a given certificate is requested once we get at least one connection with certificate_status extension in ClientHello, and certificate status won't be sent in the connection in question. This due to limitations in the OpenSSL API (certificate status callback is blocking). Note: SSL_CTX_use_certificate_chain_file() was reimplemented as it doesn't allow to access the certificate loaded via SSL_CTX.
2012-10-01OCSP stapling: the ngx_event_openssl_stapling.c file.Maxim Dounin1-0/+140
Missed in previous commit.
2012-10-01OCSP stapling: ssl_stapling_file support.Maxim Dounin1-0/+2
Very basic version without any OCSP responder query code, assuming valid DER-encoded OCSP response is present in a ssl_stapling_file configured. Such file might be produced with openssl like this: openssl ocsp -issuer root.crt -cert domain.crt -respout domain.staple \ -url http://ocsp.example.com
2012-10-01OCSP stapling: ssl_trusted_certificate directive.Maxim Dounin2-0/+29
The directive allows to specify additional trusted Certificate Authority certificates to be used during certificate verification. In contrast to ssl_client_certificate DNs of these cerificates aren't sent to a client during handshake. Trusted certificates are loaded regardless of the fact whether client certificates verification is enabled as the same certificates will be used for OCSP stapling, during construction of an OCSP request and for verification of an OCSP response. The same applies to a CRL (which is now always loaded).
2012-09-27SSL: added version checks for ssl compression workaround.Maxim Dounin1-0/+2
The SSL_COMP_get_compression_methods() is only available as an API function in OpenSSL 0.9.8+, require it explicitly to unbreak build with OpenSSL 0.9.7.
2012-09-27SSL: fixed compression workaround to remove all methods.Maxim Dounin1-3/+3
Previous code used sk_SSL_COMP_delete(ssl_comp_methods, i) while iterating stack from 0 to n, resulting in removal of only even compression methods. In real life this change is a nop, as there is only one compression method which is enabled by default in OpenSSL.
2012-08-07Explicitly ignore returned value from close() in ngx_event_core_init_conf().Andrey Belov1-1/+1
We don't have strong reason to inform about any errors reported by close() call here, and there are no other things to do with its return value. Prodded by Coverity.
2012-07-24When "debug_connection" is configured with a domain name, only the firstRuslan Ermilov1-25/+66
resolved address was used. Now all addresses will be used.
2012-07-24Fixed compilation with -Wmissing-prototypes.Ruslan Ermilov4-6/+53
2012-06-20Disabled gzip compression in OpenSSL prior to 1.0.0 version.Igor Sysoev1-0/+18
This saves about 522K per connection.
2012-05-30Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain()Valentin Bartenev1-1/+0
if SSL buffer is not used.
2012-05-14Update c->sent in ngx_ssl_send_chain() even if SSL buffer is not used.Valentin Bartenev1-0/+1
2012-05-11Accept moderation in case of EMFILE/ENFILE.Maxim Dounin1-6/+44
In case of EMFILE/ENFILE returned from accept() we disable accept events, and (in case of no accept mutex used) arm timer to re-enable them later. With accept mutex we just drop it, and rely on normal accept mutex handling to re-enable accept events once it's acquired again. As we now handle errors in question, logging level was changed to "crit" (instead of "alert" used for unknown errors). Note: the code might call ngx_enable_accept_events() multiple times if there are many listen sockets. The ngx_enable_accept_events() function was modified to check if connection is already active (via c->read->active) and skip it then, thus making multiple calls safe.
2012-04-29debug_connection: added the IPv6 and UNIX-domain socket support.Ruslan Ermilov3-34/+64
2012-04-18Fixed master exit if there is no events section (ticket #150).Maxim Dounin1-14/+21
Instead of checking if there is events{} section present in configuration in init_module handler we now do the same in init_conf handler. This allows master process to detect incorrect configuration early and reject it.
2012-04-12Fixed grammar in error messages.Ruslan Ermilov1-2/+2
2012-04-06Fixed signed integer overflows in timer code (ticket #145).Maxim Dounin1-3/+2
Integer overflow is undefined behaviour in C and this indeed caused problems on Solaris/SPARC (at least in some cases). Fix is to subtract unsigned integers instead, and then cast result to a signed one, which is implementation-defined behaviour and used to work. Strictly speaking, we should compare (unsigned) result with the maximum value of the corresponding signed integer type instead, this will be defined behaviour. This will require much more changes though, and considered to be overkill for now.
2012-04-03Fixed spelling in multiline C comments.Ruslan Ermilov4-5/+5
2012-03-05Whitespace fixes.Maxim Dounin1-0/+2