summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_recv.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-05-30Fixed runtime handling of systems without EPOLLRDHUP support.Marcus Ball1-1/+3
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().
2019-10-17Events: available bytes calculation via ioctl(FIONREAD).Maxim Dounin1-1/+35
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.
2016-05-13Improved EPOLLRDHUP handling.Valentin Bartenev1-0/+33
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.
2016-04-08Simplified ngx_unix_recv() and ngx_readv_chain().Ruslan Ermilov1-3/+1
This makes ngx_unix_recv() and ngx_udp_unix_recv() differ minimally.
2016-04-08Merged implementations of ngx_unix_recv().Valentin Bartenev1-59/+11
There's no real need in two separate implementations, with and without kqueue support.
2016-04-08Fixed small inconsistency in handling EOF among receive functions.Valentin Bartenev1-17/+18
Now all functions always drop the ready flag in this case.
2016-03-31Fixed logging.Sergey Kandaurov1-2/+2
2013-09-05Fixed handling of the ready flag with kqueue.Valentin Bartenev1-0/+1
There is nothing to do more when recv() has returned 0, so we should drop the flag.
2013-07-13Events: honor NGX_USE_GREEDY_EVENT when kqueue support is enabled.Valentin Bartenev1-1/+3
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.
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2010-06-23style fixIgor Sysoev1-2/+2
2008-01-31reset ready flag if no data is available,Igor Sysoev1-0/+1
this fixes endless loop at least in lingering close
2007-12-01axe old unused alert messageIgor Sysoev1-6/+0
2007-12-01style fixIgor Sysoev1-2/+4
2006-03-28nginx-0.3.35-RELEASE importrelease-0.3.35Igor Sysoev1-0/+2
*) 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.
2006-02-03nginx-0.3.26-RELEASE importrelease-0.3.26Igor Sysoev1-1/+1
*) 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.
2006-02-01nginx-0.3.24-RELEASE importrelease-0.3.24Igor Sysoev1-0/+15
*) 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.
2005-12-07nginx-0.3.15-RELEASE importrelease-0.3.15Igor Sysoev1-9/+5
*) 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.
2005-12-05nginx-0.3.13-RELEASE importrelease-0.3.13Igor Sysoev1-1/+1
*) Feature: the IMAP/POP3 proxy supports STARTTLS and STLS. *) Bugfix: the IMAP/POP3 proxy did not work with the select, poll, and /dev/poll methods. *) Bugfix: in SSI handling. *) Bugfix: now Solaris sendfilev() is not used to transfer the client request body to FastCGI-server via the unix domain socket. *) Bugfix: the "auth_basic" directive did not disable the authorization; the bug had appeared in 0.3.11.
2005-11-26nginx-0.3.12-RELEASE importrelease-0.3.12Igor Sysoev1-4/+8
*) 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.
2005-08-30nginx-0.1.43-RELEASE importrelease-0.1.43Igor Sysoev1-10/+2
*) Feature: the listen(2) backlog in the "listen" directive can be changed using the -HUP signal. *) Feature: the geo2nginx.pl script was added to contrib. *) Change: the FastCGI parameters with the empty values now are passed to a server. *) Bugfix: the segmentation fault occurred or the worker process may got caught in an endless loop if the proxied or FastCGI server sent the "Cache-Control" header line and the "expires" directive was used; in the proxied mode the the bug had appeared in 0.1.29.
2004-11-25nginx-0.1.9-RELEASE importrelease-0.1.9Igor Sysoev1-3/+3
*) 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.
2004-10-21nginx-0.1.2-RELEASE importrelease-0.1.2Igor Sysoev1-3/+3
*) 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.
2004-09-29nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyrightIgor Sysoev1-1/+1
2004-09-28nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused filesIgor Sysoev1-0/+5
2004-07-02nginx-0.0.7-2004-07-02-19:54:34 importIgor Sysoev1-3/+3
2004-04-28nginx-0.0.3-2004-04-28-10:14:50 importIgor Sysoev1-6/+10
2004-04-02nginx-0.0.3-2004-04-02-19:13:20 importIgor Sysoev1-1/+1
2004-03-16nginx-0.0.2-2004-03-16-10:10:12 importIgor Sysoev1-1/+1
2004-02-11nginx-0.0.2-2004-02-11-20:08:49 importIgor Sysoev1-2/+2
2004-02-10nginx-0.0.2-2004-02-10-19:23:38 importIgor Sysoev1-1/+1
2004-02-09nginx-0.0.2-2004-02-09-10:46:43 importIgor Sysoev1-47/+31
2004-01-05nginx-0.0.1-2004-01-05-23:55:48 importIgor Sysoev1-14/+36
2003-11-18nginx-0.0.1-2003-11-18-11:04:34 importIgor Sysoev1-6/+8
2003-11-14nginx-0.0.1-2003-11-14-10:20:34 importIgor Sysoev1-2/+12
2003-10-28nginx-0.0.1-2003-10-28-18:45:41 importIgor Sysoev1-6/+27
2003-10-16nginx-0.0.1-2003-10-17-00:19:16 importIgor Sysoev1-2/+5
2003-10-12nginx-0.0.1-2003-10-12-20:49:16 importIgor Sysoev1-1/+4
2003-06-11nginx-0.0.1-2003-06-11-19:28:34 importIgor Sysoev1-0/+1
2003-05-27nginx-0.0.1-2003-05-27-16:18:54 importIgor Sysoev1-55/+79
2003-05-21nginx-0.0.1-2003-05-21-17:28:21 importIgor Sysoev1-2/+4
2003-05-19nginx-0.0.1-2003-05-19-20:39:14 importIgor Sysoev1-0/+92