summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
2012-08-06Merge of r4764: debug_connection with a domain name change.Maxim Dounin1-25/+66
When "debug_connection" is configured with a domain name, only the first resolved address was used. Now all addresses will be used.
2012-08-06Merge of r4760, r4761: -Wmissing-prototypes.Maxim Dounin4-6/+53
Fixed compilation with -Wmissing-prototypes. Added a commented out -Wmissing-prototypes to CFLAGS. It is commented out to not break builds with 3rd party modules.
2012-07-02Merge of r4697: disabled gzip in OpenSSL prior to 1.0.0.Maxim Dounin1-0/+18
Disabled gzip compression in OpenSSL prior to 1.0.0 version. This saves about 522K per connection.
2012-07-02Merge of r4652: ssl without buffer should not set c->buffered.Maxim Dounin1-1/+0
Removed mistaken setting of NGX_SSL_BUFFERED flag in ngx_ssl_send_chain() if SSL buffer is not used.
2012-06-04Merge of r4630: fixed c->sent with unbuffered ssl.Maxim Dounin1-0/+1
Update c->sent in ngx_ssl_send_chain() even if SSL buffer is not used.
2012-06-04Merge of r4614, r4624-r4629, r4631: proxy recursive changes.Maxim Dounin3-34/+64
*) Added IPv6 and UNIX-domain socket support in "debug_connection" directive. *) New function ngx_http_get_forwarded_addr() to look up real client address. On input it takes an original address, string in the X-Forwarded-For format and its length, list of trusted proxies, and a flag indicating to perform the recursive search. On output it returns NGX_OK and the "deepest" valid address in a chain, or NGX_DECLINED. It supports AF_INET and AF_INET6. Additionally, original address and/or proxy may be specified as AF_UNIX. *) Realip: chains of trusted proxies and IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies, controlled by the "real_ip_recursive" directive (closes #2). It also gets full IPv6 support (closes #44) and canonical value of the $client_addr variable on address change. Example: real_ip_header X-Forwarded-For; set_real_ip_from 127.0.0.0/8; set_real_ip_from ::1; set_real_ip_from unix:; real_ip_recursive on; *) Geo: chains of trusted proxies and partial IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies, controlled by the "proxy_recursive" directive in the "geo" block. It also gets partial IPv6 support: now proxies may be specified with IPv6 addresses. Example: geo $test { ... proxy 127.0.0.1; proxy ::1; proxy_recursive; } There's also a slight change in behavior. When original client address (as specified by the "geo" directive) is one of the trusted proxies, and the value of the X-Forwarded-For request header cannot not be parsed as a valid address, an original client address will be used for lookup. Previously, 255.255.255.255 was used in this case. *) Geoip: trusted proxies support and partial IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies (closes #100), in the same scope as the geo module. Proxies are listed by the "geoip_proxy" directive, recursive search is enabled by the "geoip_proxy_recursive" directive. IPv6 is partially supported: proxies may be specified with IPv6 addresses. Example: geoip_country .../GeoIP.dat; geoip_proxy 127.0.0.1; geoip_proxy ::1; geoip_proxy 10.0.0.0/8; geoip_proxy_recursive on;
2012-06-04Merge of r4619: accept moderation on 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-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
2012-02-28Fixed spelling in single-line comments.Ruslan Ermilov3-3/+3
2012-02-27Fix of rbtree lookup on hash collisions.Maxim Dounin1-41/+31
Previous code incorrectly assumed that nodes with identical keys are linked together. This might not be true after tree rebalance. Patch by Lanshun Zhou.
2012-02-22Event pipe: fixed buffer loss in p->length case.Maxim Dounin1-1/+2
With previous code raw buffer might be lost if p->input_filter() was called on a buffer without any data and used ngx_event_pipe_add_free_buf() to return it to the free list. This eventually might cause "all buffers busy" problem, resulting in segmentation fault due to null pointer dereference in ngx_event_pipe_write_chain_to_temp_file(). In ngx_event_pipe_add_free_buf() the buffer was added to the list start due to pos == last, and then "p->free_raw_bufs = cl->next" in ngx_event_pipe_read_upstream() dropped both chain links to the buffer from the p->free_raw_bufs list. Fix is to move "p->free_raw_bufs = cl->next" before calling the p->input_filter().
2012-01-30Fixed error handling in ngx_event_connect_peer().Maxim Dounin1-6/+5
Previously if ngx_add_event() failed a connection was freed two times (once in the ngx_event_connect_peer(), and again by a caller) as pc->connection was left set. Fix is to always use ngx_close_connection() to close connection properly and set pc->connection to NULL on errors. Patch by Piotr Sikora.
2012-01-30Removed ENGINE_load_builtin_engines() call.Maxim Dounin1-2/+0
It's already called by OPENSSL_config(). Calling it again causes some openssl engines (notably GOST) to corrupt memory, as they don't expect to be created more than once.
2012-01-18Copyright updated.Maxim Konovalov29-0/+29
2012-01-11Added support for TLSv1.1, TLSv1.2 in ssl_protocols directive.Maxim Dounin2-17/+23
Support for TLSv1.1 and TLSv1.2 protocols was introduced in OpenSSL 1.0.1 (-beta1 was recently released). This change makes it possible to disable these protocols and/or enable them without other protocols.
2011-11-29Fixed AIO on Linux, broken in r4306.Maxim Dounin1-10/+10
Events from eventfd do not have c->write set, and the stale event check added in r4306 causes null pointer dereference.
2011-11-23Added shmtx interface to forcibly unlock mutexes.Maxim Dounin1-1/+2
It is currently used from master process on abnormal worker termination to unlock accept mutex (unlocking of accept mutex was broken in 1.0.2). It is expected to be used in the future to unlock other mutexes as well. Shared mutex code was rewritten to make this possible in a safe way, i.e. with a check if lock was actually held by the exited process. We again use pid to lock mutex, and use separate atomic variable for a count of processes waiting in sem_wait().
2011-11-22Protection from stale write events in epoll.Maxim Dounin1-0/+12
Stale write event may happen if epoll_wait() reported both read and write events, and processing of the read event closed descriptor. Patch by Yichun Zhang (agentzh).
2011-10-31Silently ignoring a stale global SSL error left after disabled renegotiation.Igor Sysoev1-0/+7
2011-10-31Event pipe: reduced number of file buffers used.Maxim Dounin2-22/+55
If possible we now just extend already present file buffer in p->out chain instead of keeping ngx_buf_t for each buffer we've flushed to disk. This saves about 120 bytes of memory per buffer flushed to disk, and resolves high CPU usage observed in edge cases (due to coalescing these buffers on send).
2011-10-31Event pipe: fixes for complex protocols.Maxim Dounin1-63/+20
1. In ngx_event_pipe_write_chain_to_temp_file() make sure to fully write all shadow buffers up to last_shadow. With this change recycled buffers cannot appear in p->out anymore. This also fixes segmentation faults observed due to ngx_event_pipe_write_chain_to_temp() not freeing any raw buffers while still returning NGX_OK. 2. In ngx_event_pipe_write_to_downstream() we now properly check for busy size as a size of buffers, not a size of data in these buffers. This fixes situations where all available buffers became busy (including segmentation faults due to this). 3. The ngx_event_pipe_free_shadow_raw_buf() function is dropped. It's incorrect and not needed.
2011-10-25Decrease of log level of some SSL handshake errors.Igor Sysoev1-1/+19
2011-10-07Releasing memory of idle SSL connection. This saves about 34K per SSLIgor Sysoev1-0/+4
connection. The SSL_MODE_RELEASE_BUFFERS option is available since OpenSSL 1.0.0d.
2011-10-07Disabling SSL compression. This saves about 300K per SSL connection.Igor Sysoev1-0/+4
The SSL_OP_NO_COMPRESSION option is available since OpenSSL 1.0.0.
2011-09-20Fixed loss of chain links in ngx_event_pipe_read_upstream().Maxim Dounin1-0/+1
2011-09-20Fix of cpu hog in event pipe.Maxim Dounin1-2/+2
If client closed connection in ngx_event_pipe_write_to_downstream(), buffers in the "out" chain were lost. This caused cpu hog if all available buffers were in the "out" chain. Fix is to call ngx_chain_update_chains() before checking return code of output filter to avoid loosing buffers in the "out" chain. Note that this situation (all available buffers in the "out" chain) isn't normal, it should be prevented by busy buffers limit. Though right now it may happen with complex protocols like fastcgi. This should be addressed separately.
2011-09-20The "worker_aio_requests" directive.Igor Sysoev1-3/+13
The default value is 32 AIO simultaneous requests per worker. Previously they were hardcoded to 1024, and it was too large, since Linux allocated them early on io_setup(), but not on request itself. So with default value of /proc/sys/fs/aio-max-nr equal to 65536 only 64 worker processes could be run simultaneously. 32 AIO requests are enough for modern disks even if server runs only 1 worker.
2011-09-19Replaced "can not" with "cannot" and "could not" in a bunch of places.Ruslan Ermilov2-6/+6
Fixed nearby grammar errors.
2011-09-16Fixing Linux AIO initiatialization: AIO operations are disabled if kernelIgor Sysoev1-47/+82
does not support them. Previously worker just exited.
2011-09-16Fixing Linux AIO syscalls return value handling:Igor Sysoev1-10/+11
syscall(2) uses usual libc convention, it returns -1 on error and sets errno. Obsolete _syscall(2) returns negative value of error. Thanks to Hagai Avrahami.
2011-09-15Upstream: pipe length and input_filter_init in buffered mode.Maxim Dounin2-0/+30
As long as ngx_event_pipe() has more data read from upstream than specified in p->length it's passed to input filter even if buffer isn't yet full. This allows to process data with known length without relying on connection close to signal data end. By default p->length is set to -1 in upstream module, i.e. end of data is indicated by connection close. To set it from per-protocol handlers upstream input_filter_init() now called in buffered mode (as well as in unbuffered mode).
2011-09-15API change: ngx_chain_update_chains() now requires pool.Maxim Dounin1-1/+1
The ngx_chain_update_chains() needs pool to free chain links used for buffers with non-matching tags. Providing one helps to reduce memory consumption for long-lived requests.
2011-09-01Proper setting of read->eof in pipe code.Maxim Dounin1-1/+1
Setting read->eof to 0 seems to be just a typo. It appeared in nginx-0.0.1-2003-10-28-18:45:41 import (r164), while identical code in ngx_recv.c introduced in the same import do actually set read->eof to 1. Failure to set read->eof to 1 results in EOF not being generally detectable from connection flags. On the other hand, kqueue won't report any read events on such a connection since we use EV_CLEAR. This resulted in read timeouts if such connection was cached and used for another request.
2011-09-01Proper SSL shutdown handling.Maxim Dounin1-0/+5
If connection has unsent alerts, SSL_shutdown() tries to send them even if SSL_set_shutdown(SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN) was used. This can be prevented by SSL_set_quiet_shutdown(). SSL_set_shutdown() is required nevertheless to preserve session.
2011-08-04A new fix for the case when ssl_session_cache defined, but ssl is notIgor Sysoev2-5/+3
enabled in any server. The previous r1033 does not help when unused zone becomes used after reconfiguration, so it is backed out. The initial thought was to make SSL modules independed from SSL implementation and to keep OpenSSL code dependance as much as in separate files.
2011-07-22fix SSL connection issues on platforms with 32-bit off_tIgor Sysoev1-3/+3
patch by Maxim Dounin
2011-07-22fix build by gcc46 with -Wunused-value optionIgor Sysoev1-3/+7
patch by Maxim Dounin
2011-07-20ECDHE supportIgor Sysoev2-0/+40
patch by Adrian Kotelba
2011-07-20MSIE export versions are rare now, so RSA 512 key is generated on demandIgor Sysoev2-19/+9
and is shared among all hosts instead of pregenerating for every HTTPS host on configuraiton phase. This decreases start time for configuration with large number of HTTPS hosts.
2011-05-10use POSIX semaphores in shmtx instead of sched_yield()Igor Sysoev1-0/+1
number of spinlock spins are increased twice
2011-04-23fix building by gcc 4.6 without --with-debugIgor Sysoev1-10/+3
2011-01-20fix building on Fedora 14Igor Sysoev1-1/+1
patch by Kirill A. Korinskiy
2010-12-06remove SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG becuase of CVE-2010-4180Igor Sysoev1-1/+0
2010-12-02fix building by msvc8 introduced by the previous commitIgor Sysoev1-3/+5
2010-12-02fallback to accept() if accept4() is not implemented,Igor Sysoev1-2/+21
the issue has been introduced in r3787
2010-11-25Linux accept4() supportIgor Sysoev1-0/+4