aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_readv_chain.c
Commit message (Collapse)AuthorAge
* Events: fixed EPOLLRDHUP with FIONREAD (ticket #2367).Maxim Dounin2022-07-15
| | | | | | | | | | | | | | | | | | | When reading exactly rev->available bytes, rev->available might become 0 after FIONREAD usage introduction in efd71d49bde0. On the next call of ngx_readv_chain() on systems with EPOLLRDHUP this resulted in return without any actions, that is, with rev->ready set, and this in turn resulted in no timers set in event pipe, leading to socket leaks. Fix is to reset rev->ready in ngx_readv_chain() when returning due to rev->available being 0 with EPOLLRDHUP, much like it is already done in ngx_unix_recv(). This ensures that if rev->available will become 0, on systems with EPOLLRDHUP support appropriate EPOLLRDHUP-specific handling will happen on the next ngx_readv_chain() call. While here, also synced ngx_readv_chain() to match ngx_unix_recv() and reset rev->ready when returning due to rev->available being 0 with kqueue. This is mostly cosmetic change, as rev->ready is anyway reset when rev->available is set to 0.
* Fixed runtime handling of systems without EPOLLRDHUP support.Marcus Ball2022-05-30
| | | | | | | | | | | | | | | | | | | | | | In 7583:efd71d49bde0 (nginx 1.17.5) along with introduction of the ioctl(FIONREAD) support proper handling of systems without EPOLLRDHUP support in the kernel (but with EPOLLRDHUP in headers) was broken. Before the change, rev->available was never set to 0 unless ngx_use_epoll_rdhup was also set (that is, runtime test for EPOLLRDHUP introduced in 6536:f7849bfb6d21 succeeded). After the change, rev->available might reach 0 on systems without runtime EPOLLRDHUP support, stopping further reading in ngx_readv_chain() and ngx_unix_recv(). And, if EOF happened to be already reported along with the last event, it is not reported again by epoll_wait(), leading to connection hangs and timeouts on such systems. This affects Linux kernels before 2.6.17 if nginx was compiled with newer headers, and, more importantly, emulation layers, such as DigitalOcean's App Platform's / gVisor's epoll emulation layer. Fix is to explicitly check ngx_use_epoll_rdhup before the corresponding rev->pending_eof tests in ngx_readv_chain() and ngx_unix_recv().
* Use only preallocated memory in ngx_readv_chain() (ticket #1408).Ruslan Ermilov2021-07-05
| | | | | | | | | | In d1bde5c3c5d2, the number of preallocated iovec's for ngx_readv_chain() was increased. Still, in some setups, the function might allocate memory for iovec's from a connection pool, which is only freed when closing the connection. The ngx_readv_chain() function was modified to use only preallocated memory, similarly to the ngx_writev_chain() change in 8e903522c17a.
* Events: available bytes calculation via ioctl(FIONREAD).Maxim Dounin2019-10-17
| | | | | | | | | | | | | | | | | | | | | This makes it possible to avoid looping for a long time while working with a fast enough peer when data are added to the socket buffer faster than we are able to read and process them (ticket #1431). This is basically what we already do on FreeBSD with kqueue, where information about the number of bytes in the socket buffer is returned by the kevent() call. With other event methods rev->available is now set to -1 when the socket is ready for reading. Later in ngx_recv() and ngx_recv_chain(), if full buffer is received, real number of bytes in the socket buffer is retrieved using ioctl(FIONREAD). Reading more than this number of bytes ensures that even with edge-triggered event methods the event will be triggered again, so it is safe to stop processing of the socket and switch to other connections. Using ioctl(FIONREAD) only after reading a full buffer is an optimization. With this approach we only call ioctl(FIONREAD) when there are at least two recv()/readv() calls.
* Improved EPOLLRDHUP handling.Valentin Bartenev2016-05-13
| | | | | | | | | | | | | | | | | When it's known that the kernel supports EPOLLRDHUP, there is no need in additional recv() call to get EOF or error when the flag is absent in the event generated by the kernel. A special runtime test is done at startup to detect if EPOLLRDHUP is actually supported by the kernel because epoll_ctl() silently ignores unknown flags. With this knowledge it's now possible to drop the "ready" flag for partial read. Previously, the "ready" flag was kept until the recv() returned EOF or error. In particular, this change allows the lingering close heuristics (which relies on the "ready" flag state) to actually work on Linux, and not wait for more data in most cases. The "available" flag is now used in the read event with the semantics similar to the corresponding counter in kqueue.
* Simplified ngx_unix_recv() and ngx_readv_chain().Ruslan Ermilov2016-04-08
| | | | This makes ngx_unix_recv() and ngx_udp_unix_recv() differ minimally.
* Fixed small inconsistency in handling EOF among receive functions.Valentin Bartenev2016-04-08
| | | | Now all functions always drop the ready flag in this case.
* Fixed logging.Sergey Kandaurov2016-03-31
|
* Core: added limit to recv_chain().Roman Arutyunyan2014-10-28
|
* Removed duplicate initialization of the "rev" variable.Valentin Bartenev2014-09-22
|
* Generalized definitions of the number of preallocated iovec's.Valentin Bartenev2014-08-13
| | | | No functional changes.
* Merged implementations of ngx_readv_chain().Valentin Bartenev2014-08-13
| | | | | There's no real need in two separate implementations, with and without kqueue support.
* Bigger iovec buffer in ngx_readv_chain().Maxim Dounin2014-07-28
| | | | | | This helps to reduce likelyhood of memory allocations in ngx_readv_chain(), which are known to lead to noticeable effects in some cases, see http://mailman.nginx.org/pipermail/nginx/2014-July/044512.html.
* Fixed handling of the ready flag with kqueue.Valentin Bartenev2013-09-05
| | | | | There is nothing to do more when recv() has returned 0, so we should drop the flag.
* Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.Valentin Bartenev2013-07-13
| | | | | | Currently this flag is needed for epoll and rtsig, and though these methods usually present on different platforms than kqueue, nginx can be compiled to support all of them.
* Fixed ngx_readv_chain() to honor IOV_MAX (ticket #14).Maxim Dounin2012-04-17
| | | | | | Not using full chain passed is ok as consumers are expected to check event's ready flag to determine if another call is needed, not the returned size.
* Copyright updated.Maxim Konovalov2012-01-18
|
* style fixIgor Sysoev2010-06-23
|
* nginx-0.3.35-RELEASE importrelease-0.3.35Igor Sysoev2006-03-28
| | | | | | | | *) Bugfix: the accept-filter and the TCP_DEFER_ACCEPT option were set for first "listen" directive only; the bug had appeared in 0.3.31. *) Bugfix: in the "proxy_pass" directive without the URI part in a subrequest.
* nginx-0.3.26-RELEASE importrelease-0.3.26Igor Sysoev2006-02-03
| | | | | | | | | *) Change: the "optimize_host_names" directive was renamed to the "optimize_server_names". *) Bugfix: if in the "proxy_pass" directive was no the URI part, then the main request URI was transferred to a backend while proxying the SSI subrequest.
* nginx-0.3.24-RELEASE importrelease-0.3.24Igor Sysoev2006-02-01
| | | | | | | | | | | | | | | | *) Workaround: for bug in FreeBSD kqueue. *) Bugfix: now a response generated by the "post_action" directive is not transferred to a client. *) Bugfix: the memory leaks were occurring if many log files were used. *) Bugfix: the first "proxy_redirect" directive was working inside one location. *) Bugfix: on 64-bit platforms segmentation fault may occurred on start if the many names were used in the "server_name" directives; the bug had appeared in 0.3.18.
* nginx-0.3.15-RELEASE importrelease-0.3.15Igor Sysoev2005-12-07
| | | | | | | | | | *) Feature: the new 444 code of the "return" directive to close connection. *) Feature: the "so_keepalive" directive in IMAP/POP3 proxy. *) Bugfix: if there are unclosed connection nginx now calls abort() only on gracefull quit and active "debug_points" directive.
* nginx-0.3.12-RELEASE importrelease-0.3.12Igor Sysoev2005-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *) Security: if nginx was built with the ngx_http_realip_module and the "satisfy_any on" directive was used, then access and authorization directives did not work. The ngx_http_realip_module was not built and is not built by default. *) Change: the "$time_gmt" variable name was changed to "$time_local". *) Change: the "proxy_header_buffer_size" and "fastcgi_header_buffer_size" directives was renamed to the "proxy_buffer_size" and "fastcgi_buffer_size" directives. *) Feature: the ngx_http_memcached_module. *) Feature: the "proxy_buffering" directive. *) Bugfix: the changes in accept mutex handling when the "rtsig" method was used; the bug had appeared in 0.3.0. *) Bugfix: if the client sent the "Transfer-Encoding: chunked" header line, then nginx returns the 411 error. *) Bugfix: if the "auth_basic" directive was inherited from the http level, then the realm in the "WWW-Authenticate" header line was without the "Basic realm" text. *) Bugfix: if the "combined" format was explicitly specified in the "access_log" directive, then the empty lines was written to the log; the bug had appeared in 0.3.8. *) Bugfix: nginx did not run on the sparc platform under any OS except Solaris. *) Bugfix: now it is not necessary to place space between the quoted string and closing bracket in the "if" directive.
* nginx-0.3.10-RELEASE importrelease-0.3.10Igor Sysoev2005-11-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *) Change: the "valid_referers" directive and the "$invalid_referer" variable were moved to the new ngx_http_referer_module from the ngx_http_rewrite_module. *) Change: the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent". *) Feature: the "$sent_http_..." variables. *) Feature: the "if" directive supports the "=" and "!=" operations. *) Feature: the "proxy_pass" directive supports the HTTPS protocol. *) Feature: the "proxy_set_body" directive. *) Feature: the "post_action" directive. *) Feature: the ngx_http_empty_gif_module. *) Feature: the "worker_cpu_affinity" directive for Linux. *) Bugfix: the "rewrite" directive did not unescape URI part in redirect, now it is unescaped except the %00-%25 and %7F-%FF characters. *) Bugfix: nginx could not be built by the icc 9.0 compiler. *) Bugfix: if the SSI was enabled for zero size static file, then the chunked response was encoded incorrectly.
* nginx-0.3.2-RELEASE importrelease-0.3.2Igor Sysoev2005-10-12
| | | | | | | | *) Feature: the Sun Studio 10 C compiler support. *) Feature: the "proxy_upstream_max_fails", "proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails", and "fastcgi_upstream_fail_timeout" directives.
* nginx-0.1.25-RELEASE importrelease-0.1.25Igor Sysoev2005-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
* nginx-0.1.9-RELEASE importrelease-0.1.9Igor Sysoev2004-11-25
| | | | | | | | | | | | | | | *) Bugfix: the proxied request was sent without arguments if the request contains "//", "/./", "/../" or "%XX". *) Bugfix: the large compressed responses may be transferred not completely. *) Bugfix: the files bigger than 2G was not transferred on Linux that does not support sendfile64(). *) Bugfix: while the build configuration on Linux the --with-poll_module parameter was required; the bug had appeared in 0.1.8.
* nginx-0.1.2-RELEASE importrelease-0.1.2Igor Sysoev2004-10-21
| | | | | | | | | | | | | | | | | | | | | | | *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; the bug had appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; the bug had appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
* nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyrightIgor Sysoev2004-09-29
|
* nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused filesIgor Sysoev2004-09-28
|
* nginx-0.0.7-2004-07-02-19:54:34 importIgor Sysoev2004-07-02
|
* nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_tIgor Sysoev2004-05-28
|
* nginx-0.0.3-2004-04-28-10:14:50 importIgor Sysoev2004-04-28
|
* nginx-0.0.3-2004-04-02-19:13:20 importIgor Sysoev2004-04-02
|
* nginx-0.0.3-2004-04-01-20:20:53 importIgor Sysoev2004-04-01
|
* nginx-0.0.2-2004-03-16-10:10:12 importIgor Sysoev2004-03-16
|
* nginx-0.0.2-2004-02-11-20:08:49 importIgor Sysoev2004-02-11
|
* nginx-0.0.1-2003-11-18-11:04:34 importIgor Sysoev2003-11-18
|
* nginx-0.0.1-2003-10-29-11:30:44 importIgor Sysoev2003-10-29
|
* nginx-0.0.1-2003-10-28-18:45:41 importIgor Sysoev2003-10-28
|
* nginx-0.0.1-2003-10-22-20:38:26 importIgor Sysoev2003-10-22
|
* nginx-0.0.1-2003-10-20-21:14:07 importIgor Sysoev2003-10-20
|
* nginx-0.0.1-2003-10-19-23:57:23 importIgor Sysoev2003-10-19
|
* nginx-0.0.1-2003-06-11-19:28:34 importIgor Sysoev2003-06-11
|
* nginx-0.0.1-2003-05-21-17:28:21 importIgor Sysoev2003-05-21