Mercurial > hg > nginx
annotate src/os/win32/ngx_errno.c @ 7142:b9d919b53593 stable-1.12
Stream: relaxed next upstream condition (ticket #1317).
When switching to a next upstream, some buffers could be stuck in the middle
of the filter chain. A condition existed that raised an error when this
happened. As it turned out, this condition prevented switching to a next
upstream if ssl preread was used with the TCP protocol (see the ticket).
In fact, the condition does not make sense for TCP, since after successful
connection to an upstream switching to another upstream never happens. As for
UDP, the issue with stuck buffers is unlikely to happen, but is still possible.
Specifically, if a filter delays sending data to upstream.
The condition can be relaxed to only check the "buffered" bitmask of the
upstream connection. The new condition is simpler and fixes the ticket issue
as well. Additionally, the upstream_out chain is now reset for UDP prior to
connecting to a new upstream to prevent repeating the client data twice.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 11 Sep 2017 15:32:31 +0300 |
parents | f1a0de6eb505 |
children | 746567d633ac |
rev | line source |
---|---|
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
7 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
9 #include <ngx_core.h> |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
10 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
473
diff
changeset
|
12 u_char * |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
13 ngx_strerror(ngx_err_t err, u_char *errstr, size_t size) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 { |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
15 u_int len; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
16 static u_long lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 |
461 | 18 if (size == 0) { |
19 return errstr; | |
20 } | |
21 | |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
22 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
23 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
24 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
25 if (len == 0 && lang && GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND) { |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
26 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
27 /* |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
28 * Try to use English messages first and fallback to a language, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
29 * based on locale: non-English Windows have no English messages |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
30 * at all. This way allows to use English messages at least on |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
31 * Windows with MUI. |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
32 */ |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
33 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
34 lang = 0; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
35 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
36 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
37 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
38 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
40 if (len == 0) { |
461 | 41 return ngx_snprintf(errstr, size, |
2740
e5a4be07c3eb
axe incomplete support of Winsock error descriptions on NT
Igor Sysoev <igor@sysoev.ru>
parents:
2739
diff
changeset
|
42 "FormatMessage() error:(%d)", GetLastError()); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 /* remove ".\r\n\0" */ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 while (errstr[len] == '\0' || errstr[len] == CR |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 || errstr[len] == LF || errstr[len] == '.') |
461 | 48 { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 --len; |
461 | 50 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
51 |
461 | 52 return &errstr[++len]; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 } |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
54 |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
55 |
4693
f1a0de6eb505
Fixed return type of ngx_strerror_init().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
56 ngx_int_t |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
57 ngx_strerror_init(void) |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
58 { |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
59 return NGX_OK; |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
60 } |