Skip to content

Commit c1cbc3b

Browse files
author
pangpang@hi-nginx.com
committed
update nginx to v1.19.6
1 parent 6b07cf3 commit c1cbc3b

16 files changed

+102
-28
lines changed

CHANGES

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11

2+
Changes with nginx 1.19.6 15 Dec 2020
3+
4+
*) Bugfix: "no live upstreams" errors if a "server" inside "upstream"
5+
block was marked as "down".
6+
7+
*) Bugfix: a segmentation fault might occur in a worker process if HTTPS
8+
was used; the bug had appeared in 1.19.5.
9+
10+
*) Bugfix: nginx returned the 400 response on requests like
11+
"GET http://example.com?args HTTP/1.0".
12+
13+
*) Bugfix: in the ngx_http_flv_module and ngx_http_mp4_module.
14+
Thanks to Chris Newton.
15+
16+
217
Changes with nginx 1.19.5 24 Nov 2020
318

419
*) Feature: the -e switch.

CHANGES.ru

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11

2+
Изменения в nginx 1.19.6 15.12.2020
3+
4+
*) Исправление: ошибки "no live upstreams", если server в блоке upstream
5+
был помечен как down.
6+
7+
*) Исправление: при использовании HTTPS в рабочем процессе мог произойти
8+
segmentation fault; ошибка появилась в 1.19.5.
9+
10+
*) Исправление: nginx возвращал ошибку 400 на запросы вида
11+
"GET http://example.com?args HTTP/1.0".
12+
13+
*) Исправление: в модулях ngx_http_flv_module и ngx_http_mp4_module.
14+
Спасибо Chris Newton.
15+
16+
217
Изменения в nginx 1.19.5 24.11.2020
318

419
*) Добавление: ключ -e.

html/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ <h1>Welcome to hi-nginx!</h1>
2828
<a href="https://github.com/webcpp/hi-nginx">https://github.com/webcpp/hi-nginx</a>.<br/>
2929
hi-nginx 文档:
3030
<a href="https://doc.hi-nginx.com">https://doc.hi-nginx.com</a>.<br/>
31+
hi-nginx-java 文档:
32+
<a href="https://hi-nginx-java.hi-nginx.com">https://hi-nginx-java.hi-nginx.com</a>.<br/>
3133
mongols(c++ 服务器基础设施):
3234
<a href="https://mongols.hi-nginx.com">https://mongols.hi-nginx.com</a>.<br/>
3335
mongols for python:

module/ngx_http_hi_module/module_config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern "C" {
1010
#include <ngx_http_variables.h>
1111
}
1212

13-
#define HI_NGINX_SERVER_VERSION "2.1.0"
13+
#define HI_NGINX_SERVER_VERSION "2.1.1"
1414
#define HI_NGINX_SERVER_NAME "hi-nginx/" HI_NGINX_SERVER_VERSION
1515
#define HI_NGINX_SERVER_HEAD "PoweredBy"
1616
#define SESSION_ID_NAME "SESSIONID"

src/core/nginx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define _NGINX_H_INCLUDED_
1010

1111

12-
#define nginx_version 1019005
13-
#define NGINX_VERSION "1.19.5"
12+
#define nginx_version 1019006
13+
#define NGINX_VERSION "1.19.6"
1414
#define NGINX_VER "nginx/" NGINX_VERSION
1515

1616
#ifdef NGX_BUILD

src/event/ngx_event_openssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
28802880

28812881
SSL_free(c->ssl->connection);
28822882
c->ssl = NULL;
2883+
c->recv = ngx_recv;
28832884

28842885
return NGX_OK;
28852886
}
@@ -2925,6 +2926,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
29252926
if (n == 1) {
29262927
SSL_free(c->ssl->connection);
29272928
c->ssl = NULL;
2929+
c->recv = ngx_recv;
29282930

29292931
return NGX_OK;
29302932
}
@@ -2967,6 +2969,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
29672969
if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
29682970
SSL_free(c->ssl->connection);
29692971
c->ssl = NULL;
2972+
c->recv = ngx_recv;
29702973

29712974
return NGX_OK;
29722975
}
@@ -2977,6 +2980,7 @@ ngx_ssl_shutdown(ngx_connection_t *c)
29772980

29782981
SSL_free(c->ssl->connection);
29792982
c->ssl = NULL;
2983+
c->recv = ngx_recv;
29802984

29812985
return NGX_ERROR;
29822986
}

src/http/modules/ngx_http_flv_module.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ ngx_http_flv_handler(ngx_http_request_t *r)
156156
}
157157

158158
if (!of.is_file) {
159-
160-
if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {
161-
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
162-
ngx_close_file_n " \"%s\" failed", path.data);
163-
}
164-
165159
return NGX_DECLINED;
166160
}
167161

src/http/modules/ngx_http_mp4_module.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,6 @@ ngx_http_mp4_handler(ngx_http_request_t *r)
521521
}
522522

523523
if (!of.is_file) {
524-
525-
if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {
526-
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
527-
ngx_close_file_n " \"%s\" failed", path.data);
528-
}
529-
530524
return NGX_DECLINED;
531525
}
532526

src/http/ngx_http_parse.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
380380
r->uri_start = p;
381381
state = sw_after_slash_in_uri;
382382
break;
383+
case '?':
384+
r->uri_start = p;
385+
r->args_start = p + 1;
386+
r->empty_path_in_uri = 1;
387+
state = sw_uri;
388+
break;
383389
case ' ':
384390
/*
385391
* use single "/" from request line to preserve pointers,
@@ -446,6 +452,13 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
446452
r->uri_start = p;
447453
state = sw_after_slash_in_uri;
448454
break;
455+
case '?':
456+
r->port_end = p;
457+
r->uri_start = p;
458+
r->args_start = p + 1;
459+
r->empty_path_in_uri = 1;
460+
state = sw_uri;
461+
break;
449462
case ' ':
450463
r->port_end = p;
451464
/*
@@ -1287,6 +1300,10 @@ ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
12871300
r->uri_ext = NULL;
12881301
r->args_start = NULL;
12891302

1303+
if (r->empty_path_in_uri) {
1304+
*u++ = '/';
1305+
}
1306+
12901307
ch = *p++;
12911308

12921309
while (p <= r->uri_end) {

src/http/ngx_http_request.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,13 @@ ngx_http_process_request_uri(ngx_http_request_t *r)
12241224
r->uri.len = r->uri_end - r->uri_start;
12251225
}
12261226

1227-
if (r->complex_uri || r->quoted_uri) {
1227+
if (r->complex_uri || r->quoted_uri || r->empty_path_in_uri) {
12281228

1229-
r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1);
1229+
if (r->empty_path_in_uri) {
1230+
r->uri.len++;
1231+
}
1232+
1233+
r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
12301234
if (r->uri.data == NULL) {
12311235
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
12321236
return NGX_ERROR;
@@ -1250,7 +1254,7 @@ ngx_http_process_request_uri(ngx_http_request_t *r)
12501254
r->unparsed_uri.len = r->uri_end - r->uri_start;
12511255
r->unparsed_uri.data = r->uri_start;
12521256

1253-
r->valid_unparsed_uri = r->space_in_uri ? 0 : 1;
1257+
r->valid_unparsed_uri = (r->space_in_uri || r->empty_path_in_uri) ? 0 : 1;
12541258

12551259
if (r->uri_ext) {
12561260
if (r->args_start) {
@@ -3397,8 +3401,6 @@ ngx_http_set_lingering_close(ngx_connection_t *c)
33973401
c->ssl->handler = ngx_http_set_lingering_close;
33983402
return;
33993403
}
3400-
3401-
c->recv = ngx_recv;
34023404
}
34033405
#endif
34043406

src/http/ngx_http_request.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ struct ngx_http_request_s {
470470
/* URI with " " */
471471
unsigned space_in_uri:1;
472472

473+
/* URI with empty path */
474+
unsigned empty_path_in_uri:1;
475+
473476
unsigned invalid_header:1;
474477

475478
unsigned add_uri_to_alias:1;

src/http/ngx_http_upstream_round_robin.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <ngx_http.h>
1111

1212

13-
#define ngx_http_upstream_tries(p) ((p)->number \
14-
+ ((p)->next ? (p)->next->number : 0))
13+
#define ngx_http_upstream_tries(p) ((p)->tries \
14+
+ ((p)->next ? (p)->next->tries : 0))
1515

1616

1717
static ngx_http_upstream_rr_peer_t *ngx_http_upstream_get_peer(
@@ -32,7 +32,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
3232
ngx_http_upstream_srv_conf_t *us)
3333
{
3434
ngx_url_t u;
35-
ngx_uint_t i, j, n, w;
35+
ngx_uint_t i, j, n, w, t;
3636
ngx_http_upstream_server_t *server;
3737
ngx_http_upstream_rr_peer_t *peer, **peerp;
3838
ngx_http_upstream_rr_peers_t *peers, *backup;
@@ -44,6 +44,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
4444

4545
n = 0;
4646
w = 0;
47+
t = 0;
4748

4849
for (i = 0; i < us->servers->nelts; i++) {
4950
if (server[i].backup) {
@@ -52,6 +53,10 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
5253

5354
n += server[i].naddrs;
5455
w += server[i].naddrs * server[i].weight;
56+
57+
if (!server[i].down) {
58+
t += server[i].naddrs;
59+
}
5560
}
5661

5762
if (n == 0) {
@@ -75,6 +80,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
7580
peers->number = n;
7681
peers->weighted = (w != n);
7782
peers->total_weight = w;
83+
peers->tries = t;
7884
peers->name = &us->host;
7985

8086
n = 0;
@@ -110,6 +116,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
110116

111117
n = 0;
112118
w = 0;
119+
t = 0;
113120

114121
for (i = 0; i < us->servers->nelts; i++) {
115122
if (!server[i].backup) {
@@ -118,6 +125,10 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
118125

119126
n += server[i].naddrs;
120127
w += server[i].naddrs * server[i].weight;
128+
129+
if (!server[i].down) {
130+
t += server[i].naddrs;
131+
}
121132
}
122133

123134
if (n == 0) {
@@ -139,6 +150,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
139150
backup->number = n;
140151
backup->weighted = (w != n);
141152
backup->total_weight = w;
153+
backup->tries = t;
142154
backup->name = &us->host;
143155

144156
n = 0;
@@ -214,6 +226,7 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
214226
peers->number = n;
215227
peers->weighted = 0;
216228
peers->total_weight = n;
229+
peers->tries = n;
217230
peers->name = &us->host;
218231

219232
peerp = &peers->peer;
@@ -332,6 +345,7 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
332345

333346
peers->single = (ur->naddrs == 1);
334347
peers->number = ur->naddrs;
348+
peers->tries = ur->naddrs;
335349
peers->name = &ur->host;
336350

337351
if (ur->sockaddr) {

src/http/ngx_http_upstream_round_robin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct ngx_http_upstream_rr_peers_s {
6868
#endif
6969

7070
ngx_uint_t total_weight;
71+
ngx_uint_t tries;
7172

7273
unsigned single:1;
7374
unsigned weighted:1;

src/http/v2/ngx_http_v2.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,6 @@ ngx_http_v2_lingering_close(ngx_connection_t *c)
739739
c->ssl->handler = ngx_http_v2_lingering_close;
740740
return;
741741
}
742-
743-
c->recv = ngx_recv;
744742
}
745743
#endif
746744

0 commit comments

Comments
 (0)