summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_output_chain.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-05-23Optimized chain link usage (ticket #2614).Roman Arutyunyan1-2/+8
Previously chain links could sometimes be dropped instead of being reused, which could result in increased memory consumption during long requests. A similar chain link issue in ngx_http_gzip_filter_module was fixed in da46bfc484ef (1.11.10). Based on a patch by Sangmin Lee.
2021-12-27Support for sendfile(SF_NOCACHE).Maxim Dounin1-4/+13
The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking sendfile() implementation by glebius@, makes it possible to use sendfile() along with the "directio" directive.
2021-12-27Simplified sendfile(SF_NODISKIO) usage.Maxim Dounin1-32/+0
Starting with FreeBSD 11, there is no need to use AIO operations to preload data into cache for sendfile(SF_NODISKIO) to work. Instead, sendfile() handles non-blocking loading data from disk by itself. It still can, however, return EBUSY if a page is already being loaded (for example, by a different process). If this happens, we now post an event for the next event loop iteration, so sendfile() is retried "after a short period", as manpage recommends. The limit of the number of EBUSY tolerated without any progress is preserved, but now it does not result in an alert, since on an idle system event loop iteration might be very short and EBUSY can happen many times in a row. Instead, SF_NODISKIO is simply disabled for one call once the limit is reached. With this change, sendfile(SF_NODISKIO) is now used automatically as long as sendfile() is enabled, and no longer requires "aio on;".
2021-10-29Upstream: sendfile_max_chunk support.Maxim Dounin1-0/+4
Previously, connections to upstream servers used sendfile() if it was enabled, but never honored sendfile_max_chunk. This might result in worker monopolization for a long time if large request bodies are allowed.
2018-11-26Negative size buffers detection.Maxim Dounin1-4/+60
In the past, there were several security issues which resulted in worker process memory disclosure due to buffers with negative size. It looks reasonable to check for such buffers in various places, much like we already check for zero size buffers. While here, removed "#if 1 / #endif" around zero size buffer checks. It looks highly unlikely that we'll disable these checks anytime soon.
2016-12-07Fixed spelling of logical AND operator, no functional changes.Sergey Kandaurov1-1/+1
Found by PVS-Studio.
2016-03-18Threads: task pointer stored in ngx_file_t.Maxim Dounin1-3/+8
This simplifies the interface of the ngx_thread_read() function. Additionally, most of the thread operations now explicitly set file->thread_task, file->thread_handler and file->thread_ctx, to facilitate use of thread operations in other places. (Potential problems remain with sendfile in threads though - it uses file->thread_handler as set in ngx_output_chain(), and it should not be overwritten to an incompatible one.) In collaboration with Valentin Bartenev.
2016-03-03Copy filter: fixed sendfile aio handlers to set ctx->aio.Maxim Dounin1-1/+0
Sendfile handlers (aio preload and thread handler) are called within ctx->output_filter() in ngx_output_chain(), and hence ctx->aio cannot be set directly in ngx_output_chain(). Meanwhile, it must be set to make sure loop within ngx_output_chain() will be properly terminated. There are no known cases that trigger the problem, though in theory something like aio + sub filter (something that needs body in memory, and can also free some memory buffers) + sendfile can result in "task already active" and "second aio post" alerts. The fix is to set ctx->aio in ngx_http_copy_aio_sendfile_preload() and ngx_http_copy_thread_handler(). For consistency, ctx->aio is no longer set explicitly in ngx_output_chain_copy_buf(), as it's now done in ngx_http_copy_thread_handler().
2015-03-23Output chain: free chain links in ngx_chain_writer().Maxim Dounin1-4/+12
2015-03-23Output chain: zero size buf alerts in ngx_chain_writer().Maxim Dounin1-1/+32
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.
2015-03-14Added support for offloading read() in thread pools.Valentin Bartenev1-9/+23
2015-02-11Refactored sendfile() AIO preload.Valentin Bartenev1-0/+32
This reduces layering violation and simplifies the logic of AIO preread, since it's now triggered by the send chain function itself without falling back to the copy filter. The context of AIO operation is now stored per file buffer, which makes it possible to properly handle cases when multiple buffers come from different locations, each with its own configuration.
2015-01-28Fixed AIO handling in the output chain.Valentin Bartenev1-2/+6
The ctx->aio flag must be taken into account in the short path too.
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-09-15API change: ngx_chain_update_chains() now requires pool.Maxim Dounin1-1/+2
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.
2010-10-12file AIO read may be posted inside loopIgor Sysoev1-6/+6
2010-05-14use ngx_min() and ngx_max()Igor Sysoev1-4/+1
2009-09-25uniform ngx_directio_on/off() interface with other file functionsIgor Sysoev1-2/+2
2009-09-22fail if file size was changedIgor Sysoev1-3/+1
2009-09-13fix case when the output filter should add incoming buffersIgor Sysoev1-2/+8
while waiting on file AIO completion
2009-08-28fix build by msvc, introduced in r3054Igor Sysoev1-2/+2
2009-08-28directio_alignmentIgor Sysoev1-6/+4
2009-08-28FreeBSD and Linux AIO supportIgor Sysoev1-6/+18
2009-06-02leave chain in consistent state on errorsIgor Sysoev1-2/+1
2009-05-28fix XSLT filter in SSI subrequestsIgor Sysoev1-0/+2
2008-11-20allow directio on XFSIgor Sysoev1-3/+14
2008-09-12disable directio for unaligned reads in LinuxIgor Sysoev1-0/+37
2008-09-11add filename to the log messageIgor Sysoev1-2/+2
2008-09-08fix building on 64-bit platforms, introduced in r2232Igor Sysoev1-2/+2
2008-09-05*) handle unaligned file part for directioIgor Sysoev1-41/+127
*) disable sendfile in directio mode
2008-09-03split ngx_output_chain()Igor Sysoev1-59/+64
2008-08-15fix log messageIgor Sysoev1-1/+1
2008-07-30directioIgor Sysoev1-4/+21
2008-04-09small optimizationIgor Sysoev1-9/+11
2007-06-06fix bug introduced in r1228Igor Sysoev1-1/+1
2007-06-03inherit flush flag, this fixes https proxyingIgor Sysoev1-4/+6
2007-06-03add debug loggingIgor Sysoev1-2/+3
2007-05-29an request body might not be passed to backend,Igor Sysoev1-3/+3
the bug was introduced in r1212
2007-05-28fix "proxy_pass https://"Igor Sysoev1-1/+4
2006-10-30fix formatIgor Sysoev1-1/+1
2006-01-11nginx-0.3.20-RELEASE importrelease-0.3.20Igor Sysoev1-2/+6
*) Bugfix: in SSI handling. *) Bugfix: the ngx_http_memcached_module did not support the keys in the "/usr?args" form.
2005-11-15nginx-0.3.10-RELEASE importrelease-0.3.10Igor Sysoev1-1/+2
*) 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.
2005-10-24nginx-0.3.6-RELEASE importrelease-0.3.6Igor Sysoev1-4/+4
*) Change: now the IMAP/POP3 proxy do not send the empty login to authorization server. *) Feature: the "log_format" supports the variables in the $name form. *) Bugfix: if at least in one server was no the "listen" directive, then nginx did not listen on the 80 port; the bug had appeared in 0.3.3. *) Bugfix: if the URI part is omitted in "proxy_pass" directive, the the 80 port was always used.
2005-05-23nginx-0.1.33-RELEASE importrelease-0.1.33Igor Sysoev1-2/+2
*) Bugfix: nginx could not be built with the --without-pcre parameter; the bug had appeared in 0.1.29. *) Bugfix: 3, 4, 7, and 8 the "proxy_set_header" directives in one level cause the bus fault on start up. *) Bugfix: the HTTP protocol was specified in the HTTPS redirects. *) Bugfix: if the "rewrite" directive used the captures inside the "if" directive, then the 500 error code was returned.
2005-05-12nginx-0.1.29-RELEASE importrelease-0.1.29Igor Sysoev1-2/+7
*) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; the bug had appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
2005-04-08nginx-0.1.28-RELEASE importrelease-0.1.28Igor Sysoev1-2/+4
*) Bugfix: nginx hogs CPU while proxying the huge files. *) Bugfix: nginx could not be built by gcc 4.0 on Linux.
2005-03-19nginx-0.1.25-RELEASE importrelease-0.1.25Igor Sysoev1-5/+12
*) 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.
2005-03-04nginx-0.1.24-RELEASE importrelease-0.1.24Igor Sysoev1-12/+13
*) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI variables. *) Bugfix: the ngx_http_autoindex_module may some times return the 404 response for existent directory, if this directory was used in "alias" directive. *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large responses. *) Bugfix: the lack of the "Referer" header line was always accounted as valid referrer.
2005-01-25nginx-0.1.16-RELEASE importrelease-0.1.16Igor Sysoev1-1/+11
*) Bugfix: if the response were transferred by chunks, then on the HEAD request the final chunk was issued. *) Bugfix: the "Connection: keep-alive" header were issued, even if the keepalive_timeout directive forbade the keep-alive use. *) Bugfix: the errors in the ngx_http_fastcgi_module caused the segmentation faults. *) Bugfix: the compressed response encrypted by SSL may not transferred complete. *) Bugfix: the TCP-specific TCP_NODELAY, TCP_NOPSUH, and TCP_CORK options, are not used for the unix domain sockets. *) Feature: the rewrite directive supports the arguments rewriting. *) Bugfix: the response code 400 was returned for the POST request with the "Content-Length: 0" header; the bug had appeared in 0.1.14.
2005-01-18nginx-0.1.14-RELEASE importrelease-0.1.14Igor Sysoev1-1/+1
*) Feature: the autoconfiguration directives: --http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and --http-fastcgi-temp-path=PATH *) Change: the directory name for the temporary files with the client request body is specified by directive client_body_temp_path, by default it is <prefix>/client_body_temp. *) Feature: the ngx_http_fastcgi_module and the directives: fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params, fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout, fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers, fastcgi_busy_buffers_size, fastcgi_temp_path, fastcgi_max_temp_file_size, fastcgi_temp_file_write_size, fastcgi_next_upstream, and fastcgi_x_powered_by. *) Bugfix: the "[alert] zero size buf" error; the bug had appeared in 0.1.3. *) Change: the URI must be specified after the host name in the proxy_pass directive. *) Change: the %3F symbol in the URI was considered as the argument string start. *) Feature: the unix domain sockets support in the ngx_http_proxy_module. *) Feature: the ssl_engine and ssl_ciphers directives. Thanks to Sergey Skvortsov for SSL-accelerator.