Mercurial > hg > nginx
annotate misc/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 | 782535848b3e |
children | 0d9e536ec628 |
rev | line source |
---|---|
681 | 1 |
2725 | 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:
5131
diff
changeset
|
3 | sed -e 's/^.*"\(.*\)".*/\1/') |
2725 | 4 NGINX = nginx-$(VER) |
5 TEMP = tmp | |
6 | |
6855
c2c13f1f47fd
Win32: added a variable to specify compiler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6738
diff
changeset
|
7 CC = cl |
2725 | 8 OBJS = objs.msvc8 |
9180
782535848b3e
Updated OpenSSL and zlib used for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9148
diff
changeset
|
9 OPENSSL = openssl-3.0.11 |
782535848b3e
Updated OpenSSL and zlib used for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9148
diff
changeset
|
10 ZLIB = zlib-1.3 |
7988
8af85c66da94
Updated OpenSSL and PCRE used for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7917
diff
changeset
|
11 PCRE = pcre2-10.39 |
681 | 12 |
13 | |
5131
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
14 release: export |
681 | 15 |
16 mv $(TEMP)/$(NGINX)/auto/configure $(TEMP)/$(NGINX) | |
17 | |
18 mv $(TEMP)/$(NGINX)/docs/text/LICENSE $(TEMP)/$(NGINX) | |
19 mv $(TEMP)/$(NGINX)/docs/text/README $(TEMP)/$(NGINX) | |
20 mv $(TEMP)/$(NGINX)/docs/html $(TEMP)/$(NGINX) | |
3801
569716d0e447
add man page in release tarball and fix man building procedure
Igor Sysoev <igor@sysoev.ru>
parents:
3717
diff
changeset
|
21 mv $(TEMP)/$(NGINX)/docs/man $(TEMP)/$(NGINX) |
681 | 22 |
23 $(MAKE) -f docs/GNUmakefile changes | |
24 | |
25 rm -r $(TEMP)/$(NGINX)/docs | |
26 rm -r $(TEMP)/$(NGINX)/misc | |
27 | |
704
58bd27d72519
fix bug introduced with snapshot support
Igor Sysoev <igor@sysoev.ru>
parents:
701
diff
changeset
|
28 tar -c -z -f $(NGINX).tar.gz --directory $(TEMP) $(NGINX) |
58bd27d72519
fix bug introduced with snapshot support
Igor Sysoev <igor@sysoev.ru>
parents:
701
diff
changeset
|
29 |
701 | 30 |
5131
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
31 export: |
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
32 rm -rf $(TEMP) |
5212 | 33 hg archive -X '.hg*' $(TEMP)/$(NGINX) |
5131
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
34 |
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
35 |
4211
effc7962aebe
Moving RELEASE target in more safe place.
Igor Sysoev <igor@sysoev.ru>
parents:
4181
diff
changeset
|
36 RELEASE: |
5131
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
37 hg ci -m nginx-$(VER)-RELEASE |
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
38 hg tag -m "release-$(VER) tag" release-$(VER) |
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
39 |
5212 | 40 $(MAKE) -f misc/GNUmakefile release |
4211
effc7962aebe
Moving RELEASE target in more safe place.
Igor Sysoev <igor@sysoev.ru>
parents:
4181
diff
changeset
|
41 |
effc7962aebe
Moving RELEASE target in more safe place.
Igor Sysoev <igor@sysoev.ru>
parents:
4181
diff
changeset
|
42 |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
43 win32: |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
44 ./auto/configure \ |
6855
c2c13f1f47fd
Win32: added a variable to specify compiler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6738
diff
changeset
|
45 --with-cc=$(CC) \ |
4894
0156fd6f48fa
Style, parentheses instead of braces in misc/GNUMakefile.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4843
diff
changeset
|
46 --builddir=$(OBJS) \ |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
47 --with-debug \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
48 --prefix= \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
49 --conf-path=conf/nginx.conf \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
50 --pid-path=logs/nginx.pid \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
51 --http-log-path=logs/access.log \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
52 --error-log-path=logs/error.log \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
53 --sbin-path=nginx.exe \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
54 --http-client-body-temp-path=temp/client_body_temp \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
55 --http-proxy-temp-path=temp/proxy_temp \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
56 --http-fastcgi-temp-path=temp/fastcgi_temp \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
57 --http-scgi-temp-path=temp/scgi_temp \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
58 --http-uwsgi-temp-path=temp/uwsgi_temp \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
59 --with-cc-opt=-DFD_SETSIZE=1024 \ |
4894
0156fd6f48fa
Style, parentheses instead of braces in misc/GNUMakefile.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4843
diff
changeset
|
60 --with-pcre=$(OBJS)/lib/$(PCRE) \ |
0156fd6f48fa
Style, parentheses instead of braces in misc/GNUMakefile.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4843
diff
changeset
|
61 --with-zlib=$(OBJS)/lib/$(ZLIB) \ |
6936
0d4f602dc927
Added HTTP/2 to win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6884
diff
changeset
|
62 --with-http_v2_module \ |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
63 --with-http_realip_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
64 --with-http_addition_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
65 --with-http_sub_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
66 --with-http_dav_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
67 --with-http_stub_status_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
68 --with-http_flv_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
69 --with-http_mp4_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
70 --with-http_gunzip_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
71 --with-http_gzip_static_module \ |
5335
1d0523f54a9f
Added auth request to win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5236
diff
changeset
|
72 --with-http_auth_request_module \ |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
73 --with-http_random_index_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
74 --with-http_secure_link_module \ |
6318
3250a5783787
Added slice module to win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6231
diff
changeset
|
75 --with-http_slice_module \ |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
76 --with-mail \ |
6134
96e22e4f1b03
Added stream module to win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6037
diff
changeset
|
77 --with-stream \ |
8162
252a7acd35ce
Added stream modules realip and ssl_preread to win32 builds.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8154
diff
changeset
|
78 --with-stream_realip_module \ |
252a7acd35ce
Added stream modules realip and ssl_preread to win32 builds.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8154
diff
changeset
|
79 --with-stream_ssl_preread_module \ |
4894
0156fd6f48fa
Style, parentheses instead of braces in misc/GNUMakefile.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4843
diff
changeset
|
80 --with-openssl=$(OBJS)/lib/$(OPENSSL) \ |
7489
af8abe105348
Win32: avoid using CFLAGS, just add define instead.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7487
diff
changeset
|
81 --with-openssl-opt="no-asm no-tests -D_WIN32_WINNT=0x0501" \ |
4842
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
82 --with-http_ssl_module \ |
d59fff553840
Helper target "win32" to run configure for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4779
diff
changeset
|
83 --with-mail_ssl_module \ |
6724
a6d116645c51
Configure: removed the --with-ipv6 option.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6613
diff
changeset
|
84 --with-stream_ssl_module |
681 | 85 |
5131
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
86 |
566cd32d8bac
Misc: support for Mercurial repositories.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5130
diff
changeset
|
87 zip: export |
2725 | 88 rm -f $(NGINX).zip |
89 | |
5129
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
90 mkdir -p $(TEMP)/$(NGINX)/docs.new |
2725 | 91 mkdir -p $(TEMP)/$(NGINX)/logs |
92 mkdir -p $(TEMP)/$(NGINX)/temp | |
93 | |
4779
117f3284e0de
Removed the need in Perl to generate ZIP archive of nginx/Windows.
Ruslan Ermilov <ru@nginx.com>
parents:
4774
diff
changeset
|
94 sed -i '' -e "s/$$/`printf '\r'`/" $(TEMP)/$(NGINX)/conf/* |
2725 | 95 |
5129
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
96 mv $(TEMP)/$(NGINX)/docs/text/LICENSE $(TEMP)/$(NGINX)/docs.new |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
97 mv $(TEMP)/$(NGINX)/docs/text/README $(TEMP)/$(NGINX)/docs.new |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
98 mv $(TEMP)/$(NGINX)/docs/html $(TEMP)/$(NGINX) |
2725 | 99 |
5129
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
100 rm -r $(TEMP)/$(NGINX)/docs |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
101 mv $(TEMP)/$(NGINX)/docs.new $(TEMP)/$(NGINX)/docs |
2725 | 102 |
103 cp -p $(OBJS)/nginx.exe $(TEMP)/$(NGINX) | |
104 | |
5129
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
105 $(MAKE) -f docs/GNUmakefile changes |
2725 | 106 mv $(TEMP)/$(NGINX)/CHANGES* $(TEMP)/$(NGINX)/docs/ |
107 | |
9148
f101bccb38e1
Updated OpenSSL used for win32 builds.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8162
diff
changeset
|
108 cp -p $(OBJS)/lib/$(OPENSSL)/LICENSE.txt \ |
2725 | 109 $(TEMP)/$(NGINX)/docs/OpenSSL.LICENSE |
110 | |
2871
c7fe4b9118d2
fix "make zip", the bug has been introduced in r2841
Igor Sysoev <igor@sysoev.ru>
parents:
2734
diff
changeset
|
111 cp -p $(OBJS)/lib/$(PCRE)/LICENCE \ |
c7fe4b9118d2
fix "make zip", the bug has been introduced in r2841
Igor Sysoev <igor@sysoev.ru>
parents:
2734
diff
changeset
|
112 $(TEMP)/$(NGINX)/docs/PCRE.LICENCE |
2725 | 113 |
4779
117f3284e0de
Removed the need in Perl to generate ZIP archive of nginx/Windows.
Ruslan Ermilov <ru@nginx.com>
parents:
4774
diff
changeset
|
114 sed -ne '/^ (C) 1995-20/,/^ jloup@gzip\.org/p' \ |
2725 | 115 $(OBJS)/lib/$(ZLIB)/README \ |
116 > $(TEMP)/$(NGINX)/docs/zlib.LICENSE | |
117 | |
118 touch -r $(OBJS)/lib/$(ZLIB)/README \ | |
119 $(TEMP)/$(NGINX)/docs/zlib.LICENSE | |
120 | |
5129
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
121 rm -r $(TEMP)/$(NGINX)/auto |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
122 rm -r $(TEMP)/$(NGINX)/misc |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
123 rm -r $(TEMP)/$(NGINX)/src |
96ee76fda991
Misc: switch to single export operation in "zip" target.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5065
diff
changeset
|
124 |
2725 | 125 cd $(TEMP) && zip -r ../$(NGINX).zip $(NGINX) |
126 | |
127 | |
128 icons: src/os/win32/nginx.ico | |
681 | 129 |
2734 | 130 # 48x48, 32x32 and 16x16 icons |
681 | 131 |
2734 | 132 src/os/win32/nginx.ico: src/os/win32/nginx_icon48.xpm \ |
133 src/os/win32/nginx_icon32.xpm \ | |
681 | 134 src/os/win32/nginx_icon16.xpm |
135 | |
136 test -d $(TEMP) || mkdir $(TEMP) | |
137 | |
2734 | 138 xpmtoppm --alphaout=$(TEMP)/nginx48.pbm \ |
139 src/os/win32/nginx_icon48.xpm > $(TEMP)/nginx48.ppm | |
140 | |
681 | 141 xpmtoppm --alphaout=$(TEMP)/nginx32.pbm \ |
142 src/os/win32/nginx_icon32.xpm > $(TEMP)/nginx32.ppm | |
143 | |
144 xpmtoppm --alphaout=$(TEMP)/nginx16.pbm \ | |
145 src/os/win32/nginx_icon16.xpm > $(TEMP)/nginx16.ppm | |
146 | |
147 ppmtowinicon -output src/os/win32/nginx.ico -andpgms \ | |
2734 | 148 $(TEMP)/nginx48.ppm $(TEMP)/nginx48.pbm \ |
681 | 149 $(TEMP)/nginx32.ppm $(TEMP)/nginx32.pbm \ |
150 $(TEMP)/nginx16.ppm $(TEMP)/nginx16.pbm |