annotate docs/GNUmakefile @ 9203:0de20f43db25

Fixed request termination with AIO and subrequests (ticket #2555). When a request was terminated due to an error via ngx_http_terminate_request() while an AIO operation was running in a subrequest, various issues were observed. This happened because ngx_http_request_finalizer() was only set in the subrequest where ngx_http_terminate_request() was called, but not in the subrequest where the AIO operation was running. After completion of the AIO operation normal processing of the subrequest was resumed, leading to issues. In particular, in case of the upstream module, termination of the request called upstream cleanup, which closed the upstream connection. Attempts to further work with the upstream connection after AIO operation completion resulted in segfaults in ngx_ssl_recv(), "readv() failed (9: Bad file descriptor) while reading upstream" errors, or socket leaks. In ticket #2555, issues were observed with the following configuration with cache background update (with thread writing instrumented to introduce a delay, when a client closes the connection during an update): location = /background-and-aio-write { proxy_pass ... proxy_cache one; proxy_cache_valid 200 1s; proxy_cache_background_update on; proxy_cache_use_stale updating; aio threads; aio_write on; limit_rate 1000; } Similarly, the same issue can be seen with SSI, and can be caused by errors in subrequests, such as in the following configuration (where "/proxy" uses AIO, and "/sleep" returns 444 after some delay, causing request termination): location = /ssi-active-boom { ssi on; ssi_types *; return 200 ' <!--#include virtual="/proxy" --> <!--#include virtual="/sleep" --> '; limit_rate 1000; } Or the same with both AIO operation and the error in non-active subrequests (which needs slightly different handling, see below): location = /ssi-non-active-boom { ssi on; ssi_types *; return 200 ' <!--#include virtual="/static" --> <!--#include virtual="/proxy" --> <!--#include virtual="/sleep" --> '; limit_rate 1000; } Similarly, issues can be observed with just static files. However, with static files potential impact is limited due to timeout safeguards in ngx_http_writer(), and the fact that c->error is set during request termination. In a simple configuration with an AIO operation in the active subrequest, such as in the following configuration, the connection is closed right after completion of the AIO operation anyway, since ngx_http_writer() tries to write to the connection and fails due to c->error set: location = /ssi-active-static-boom { ssi on; ssi_types *; return 200 ' <!--#include virtual="/static-aio" --> <!--#include virtual="/sleep" --> '; limit_rate 1000; } In the following configuration, with an AIO operation in a non-active subrequest, the connection is closed only after send_timeout expires: location = /ssi-non-active-static-boom { ssi on; ssi_types *; return 200 ' <!--#include virtual="/static" --> <!--#include virtual="/static-aio" --> <!--#include virtual="/sleep" --> '; limit_rate 1000; } Fix is to introduce r->main->terminated flag, which is to be checked by AIO event handlers when the r->main->blocked counter is decremented. When the flag is set, handlers are expected to wake up the connection instead of the subrequest (which might be already cleaned up). Additionally, now ngx_http_request_finalizer() is always set in the active subrequest, so waking up the connection properly finalizes the request even if termination happened in a non-active subrequest.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 30 Jan 2024 03:20:05 +0300
parents f303f3e43f7b
children 1bc938b270dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
775
a452a0e13539 check nginx.pm version
Igor Sysoev <igor@sysoev.ru>
parents: 681
diff changeset
2 VER= $(shell grep 'define NGINX_VERSION' src/core/nginx.h \
5147
864030a4ff2a Configure: unified nginx version computation constructs.
Ruslan Ermilov <ru@nginx.com>
parents: 4831
diff changeset
3 | sed -e 's/^.*"\(.*\)".*/\1/')
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 NGINX= nginx-$(VER)
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 TEMP= tmp
5585
f303f3e43f7b Docs: switched from java XSLScript to xslscript.pl.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5147
diff changeset
6 XSLS?= xslscript.pl
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8
4187
b9dade63fcc2 The reference documentation is moving elsewhere.
Ruslan Ermilov <ru@nginx.com>
parents: 4110
diff changeset
9 all: changes
4068
22364b1f61c9 Initial English translation of Core and HTTP Core modules.
Ruslan Ermilov <ru@nginx.com>
parents: 4013
diff changeset
10
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 changes: $(TEMP)/$(NGINX)/CHANGES.ru \
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 $(TEMP)/$(NGINX)/CHANGES
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
4831
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
15 $(TEMP)/$(NGINX)/CHANGES.ru: docs/dtd/changes.dtd \
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
16 docs/xml/nginx/changes.xml \
4013
b427290fb6bc - Added missing dependencies for the CHANGES{,ru} targets.
Ruslan Ermilov <ru@nginx.com>
parents: 3999
diff changeset
17 docs/xml/change_log_conf.xml \
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 docs/xslt/changes.xslt
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19
4776
3032f4854b81 Simplified makefile that builds CHANGES.
Ruslan Ermilov <ru@nginx.com>
parents: 4187
diff changeset
20 mkdir -p $(TEMP)/$(NGINX)
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21
4831
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
22 xmllint --noout --valid docs/xml/nginx/changes.xml
4013
b427290fb6bc - Added missing dependencies for the CHANGES{,ru} targets.
Ruslan Ermilov <ru@nginx.com>
parents: 3999
diff changeset
23 xsltproc --stringparam lang ru \
4776
3032f4854b81 Simplified makefile that builds CHANGES.
Ruslan Ermilov <ru@nginx.com>
parents: 4187
diff changeset
24 -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26
4831
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
27 $(TEMP)/$(NGINX)/CHANGES: docs/dtd/changes.dtd \
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
28 docs/xml/nginx/changes.xml \
4013
b427290fb6bc - Added missing dependencies for the CHANGES{,ru} targets.
Ruslan Ermilov <ru@nginx.com>
parents: 3999
diff changeset
29 docs/xml/change_log_conf.xml \
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 docs/xslt/changes.xslt
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
4776
3032f4854b81 Simplified makefile that builds CHANGES.
Ruslan Ermilov <ru@nginx.com>
parents: 4187
diff changeset
32 mkdir -p $(TEMP)/$(NGINX)
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
4831
5e3bda6f5208 Pass changes.xml thru xmllint when generating CHANGES and CHANGES.ru.
Ruslan Ermilov <ru@nginx.com>
parents: 4776
diff changeset
34 xmllint --noout --valid docs/xml/nginx/changes.xml
4013
b427290fb6bc - Added missing dependencies for the CHANGES{,ru} targets.
Ruslan Ermilov <ru@nginx.com>
parents: 3999
diff changeset
35 xsltproc --stringparam lang en \
4776
3032f4854b81 Simplified makefile that builds CHANGES.
Ruslan Ermilov <ru@nginx.com>
parents: 4187
diff changeset
36 -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38
5585
f303f3e43f7b Docs: switched from java XSLScript to xslscript.pl.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5147
diff changeset
39 docs/xslt/changes.xslt: docs/xsls/changes.xsls
681
7e24168b0853 nginx-0.4.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40
5585
f303f3e43f7b Docs: switched from java XSLScript to xslscript.pl.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5147
diff changeset
41 $(XSLS) -o $@ $<