Skip to content

Commit 6c264bc

Browse files
author
pangpang@hi-nginx.com
committed
update nginx to v1.19.10
1 parent 44ec06b commit 6c264bc

16 files changed

+146
-43
lines changed

CHANGES

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

2+
Changes with nginx 1.19.10 13 Apr 2021
3+
4+
*) Change: the default value of the "keepalive_requests" directive was
5+
changed to 1000.
6+
7+
*) Feature: the "keepalive_time" directive.
8+
9+
*) Feature: the $connection_time variable.
10+
11+
*) Workaround: "gzip filter failed to use preallocated memory" alerts
12+
appeared in logs when using zlib-ng.
13+
14+
215
Changes with nginx 1.19.9 30 Mar 2021
316

417
*) Bugfix: nginx could not be built with the mail proxy module, but

CHANGES.ru

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

2+
Изменения в nginx 1.19.10 13.04.2021
3+
4+
*) Изменение: в директиве keepalive_requests значение по умолчанию
5+
изменено на 1000.
6+
7+
*) Добавление: директива keepalive_time.
8+
9+
*) Добавление: переменная $connection_time.
10+
11+
*) Изменение: при использовании zlib-ng в логах появлялись сообщения
12+
"gzip filter failed to use preallocated memory".
13+
14+
215
Изменения в nginx 1.19.9 30.03.2021
316

417
*) Исправление: nginx не собирался с почтовым прокси-сервером, но без

auto/os/linux

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ if [ $ngx_found = yes ]; then
8686
ee.data.ptr = NULL;
8787
epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
8888
. auto/feature
89+
90+
91+
# eventfd()
92+
93+
ngx_feature="eventfd()"
94+
ngx_feature_name="NGX_HAVE_EVENTFD"
95+
ngx_feature_run=no
96+
ngx_feature_incs="#include <sys/eventfd.h>"
97+
ngx_feature_path=
98+
ngx_feature_libs=
99+
ngx_feature_test="(void) eventfd(0, 0)"
100+
. auto/feature
101+
102+
if [ $ngx_found = yes ]; then
103+
have=NGX_HAVE_SYS_EVENTFD_H . auto/have
104+
fi
105+
106+
107+
if [ $ngx_found = no ]; then
108+
109+
ngx_feature="eventfd() (SYS_eventfd)"
110+
ngx_feature_incs="#include <sys/syscall.h>"
111+
ngx_feature_test="(void) SYS_eventfd"
112+
. auto/feature
113+
fi
89114
fi
90115

91116

auto/unix

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -582,29 +582,6 @@ Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
582582
END
583583
exit 1
584584
fi
585-
586-
else
587-
588-
ngx_feature="eventfd()"
589-
ngx_feature_name="NGX_HAVE_EVENTFD"
590-
ngx_feature_run=no
591-
ngx_feature_incs="#include <sys/eventfd.h>"
592-
ngx_feature_path=
593-
ngx_feature_libs=
594-
ngx_feature_test="(void) eventfd(0, 0)"
595-
. auto/feature
596-
597-
if [ $ngx_found = yes ]; then
598-
have=NGX_HAVE_SYS_EVENTFD_H . auto/have
599-
fi
600-
601-
if [ $ngx_found = no ]; then
602-
603-
ngx_feature="eventfd() (SYS_eventfd)"
604-
ngx_feature_incs="#include <sys/syscall.h>"
605-
ngx_feature_test="(void) SYS_eventfd"
606-
. auto/feature
607-
fi
608585
fi
609586

610587

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 1019009
13-
#define NGINX_VERSION "1.19.9"
12+
#define nginx_version 1019010
13+
#define NGINX_VERSION "1.19.10"
1414
#define NGINX_VER "nginx/" NGINX_VERSION
1515

1616
#ifdef NGX_BUILD

src/core/ngx_connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct ngx_connection_s {
162162

163163
ngx_atomic_uint_t number;
164164

165+
ngx_msec_t start_time;
165166
ngx_uint_t requests;
166167

167168
unsigned buffered:8;

src/core/ngx_resolver.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,6 +4459,8 @@ ngx_udp_connect(ngx_resolver_connection_t *rec)
44594459

44604460
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
44614461

4462+
c->start_time = ngx_current_msec;
4463+
44624464
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, &rec->log, 0,
44634465
"connect to %V, fd:%d #%uA", &rec->server, s, c->number);
44644466

@@ -4545,6 +4547,8 @@ ngx_tcp_connect(ngx_resolver_connection_t *rec)
45454547

45464548
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
45474549

4550+
c->start_time = ngx_current_msec;
4551+
45484552
if (ngx_add_conn) {
45494553
if (ngx_add_conn(c) == NGX_ERROR) {
45504554
goto failed;

src/event/ngx_event_accept.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ ngx_event_accept(ngx_event_t *ev)
256256

257257
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
258258

259+
c->start_time = ngx_current_msec;
260+
259261
#if (NGX_STAT_STUB)
260262
(void) ngx_atomic_fetch_add(ngx_stat_handled, 1);
261263
#endif

src/event/ngx_event_connect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ ngx_event_connect_peer(ngx_peer_connection_t *pc)
193193

194194
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
195195

196+
c->start_time = ngx_current_msec;
197+
196198
if (ngx_add_conn) {
197199
if (ngx_add_conn(c) == NGX_ERROR) {
198200
goto failed;

src/event/ngx_event_udp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ ngx_event_recvmsg(ngx_event_t *ev)
363363

364364
c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
365365

366+
c->start_time = ngx_current_msec;
367+
366368
#if (NGX_STAT_STUB)
367369
(void) ngx_atomic_fetch_add(ngx_stat_handled, 1);
368370
#endif

src/http/modules/ngx_http_gzip_filter_module.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ typedef struct {
5656
unsigned done:1;
5757
unsigned nomem:1;
5858
unsigned buffering:1;
59-
unsigned intel:1;
59+
unsigned zlib_ng:1;
6060

6161
size_t zin;
6262
size_t zout;
@@ -213,7 +213,7 @@ static ngx_str_t ngx_http_gzip_ratio = ngx_string("gzip_ratio");
213213
static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
214214
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
215215

216-
static ngx_uint_t ngx_http_gzip_assume_intel;
216+
static ngx_uint_t ngx_http_gzip_assume_zlib_ng;
217217

218218

219219
static ngx_int_t
@@ -501,28 +501,30 @@ ngx_http_gzip_filter_memory(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx)
501501
* 8K is for zlib deflate_state, it takes
502502
* *) 5816 bytes on i386 and sparc64 (32-bit mode)
503503
* *) 5920 bytes on amd64 and sparc64
504+
*
505+
* A zlib variant from Intel (https://github.com/jtkukunas/zlib)
506+
* uses additional 16-byte padding in one of window-sized buffers.
504507
*/
505508

506-
if (!ngx_http_gzip_assume_intel) {
507-
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
509+
if (!ngx_http_gzip_assume_zlib_ng) {
510+
ctx->allocated = 8192 + 16 + (1 << (wbits + 2))
511+
+ (1 << (memlevel + 9));
508512

509513
} else {
510514
/*
511-
* A zlib variant from Intel, https://github.com/jtkukunas/zlib.
512-
* It can force window bits to 13 for fast compression level,
513-
* on processors with SSE 4.2 it uses 64K hash instead of scaling
514-
* it from the specified memory level, and also introduces
515-
* 16-byte padding in one out of the two window-sized buffers.
515+
* Another zlib variant, https://github.com/zlib-ng/zlib-ng.
516+
* It forces window bits to 13 for fast compression level,
517+
* uses 16-byte padding in one of window-sized buffers, and
518+
* uses 128K hash.
516519
*/
517520

518521
if (conf->level == 1) {
519522
wbits = ngx_max(wbits, 13);
520523
}
521524

522525
ctx->allocated = 8192 + 16 + (1 << (wbits + 2))
523-
+ (1 << (ngx_max(memlevel, 8) + 8))
524-
+ (1 << (memlevel + 8));
525-
ctx->intel = 1;
526+
+ 131072 + (1 << (memlevel + 8));
527+
ctx->zlib_ng = 1;
526528
}
527529
}
528530

@@ -945,13 +947,13 @@ ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
945947
return p;
946948
}
947949

948-
if (ctx->intel) {
950+
if (ctx->zlib_ng) {
949951
ngx_log_error(NGX_LOG_ALERT, ctx->request->connection->log, 0,
950952
"gzip filter failed to use preallocated memory: "
951953
"%ud of %ui", items * size, ctx->allocated);
952954

953955
} else {
954-
ngx_http_gzip_assume_intel = 1;
956+
ngx_http_gzip_assume_zlib_ng = 1;
955957
}
956958

957959
p = ngx_palloc(ctx->request->pool, items * size);

src/http/modules/ngx_http_upstream_keepalive_module.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
typedef struct {
1414
ngx_uint_t max_cached;
1515
ngx_uint_t requests;
16+
ngx_msec_t time;
1617
ngx_msec_t timeout;
1718

1819
ngx_queue_t cache;
@@ -86,6 +87,13 @@ static ngx_command_t ngx_http_upstream_keepalive_commands[] = {
8687
0,
8788
NULL },
8889

90+
{ ngx_string("keepalive_time"),
91+
NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
92+
ngx_conf_set_msec_slot,
93+
NGX_HTTP_SRV_CONF_OFFSET,
94+
offsetof(ngx_http_upstream_keepalive_srv_conf_t, time),
95+
NULL },
96+
8997
{ ngx_string("keepalive_timeout"),
9098
NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
9199
ngx_conf_set_msec_slot,
@@ -149,8 +157,9 @@ ngx_http_upstream_init_keepalive(ngx_conf_t *cf,
149157
kcf = ngx_http_conf_upstream_srv_conf(us,
150158
ngx_http_upstream_keepalive_module);
151159

160+
ngx_conf_init_msec_value(kcf->time, 3600000);
152161
ngx_conf_init_msec_value(kcf->timeout, 60000);
153-
ngx_conf_init_uint_value(kcf->requests, 100);
162+
ngx_conf_init_uint_value(kcf->requests, 1000);
154163

155164
if (kcf->original_init_upstream(cf, us) != NGX_OK) {
156165
return NGX_ERROR;
@@ -326,6 +335,10 @@ ngx_http_upstream_free_keepalive_peer(ngx_peer_connection_t *pc, void *data,
326335
goto invalid;
327336
}
328337

338+
if (ngx_current_msec - c->start_time > kp->conf->time) {
339+
goto invalid;
340+
}
341+
329342
if (!u->keepalive) {
330343
goto invalid;
331344
}
@@ -513,6 +526,7 @@ ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf)
513526
* conf->max_cached = 0;
514527
*/
515528

529+
conf->time = NGX_CONF_UNSET_MSEC;
516530
conf->timeout = NGX_CONF_UNSET_MSEC;
517531
conf->requests = NGX_CONF_UNSET_UINT;
518532

src/http/ngx_http_core_module.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ static ngx_command_t ngx_http_core_commands[] = {
495495
offsetof(ngx_http_core_loc_conf_t, limit_rate_after),
496496
NULL },
497497

498+
{ ngx_string("keepalive_time"),
499+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
500+
ngx_conf_set_msec_slot,
501+
NGX_HTTP_LOC_CONF_OFFSET,
502+
offsetof(ngx_http_core_loc_conf_t, keepalive_time),
503+
NULL },
504+
498505
{ ngx_string("keepalive_timeout"),
499506
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
500507
ngx_http_core_keepalive,
@@ -1335,6 +1342,11 @@ ngx_http_update_location_config(ngx_http_request_t *r)
13351342
} else if (r->connection->requests >= clcf->keepalive_requests) {
13361343
r->keepalive = 0;
13371344

1345+
} else if (ngx_current_msec - r->connection->start_time
1346+
> clcf->keepalive_time)
1347+
{
1348+
r->keepalive = 0;
1349+
13381350
} else if (r->headers_in.msie6
13391351
&& r->method == NGX_HTTP_POST
13401352
&& (clcf->keepalive_disable
@@ -3500,6 +3512,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
35003512
clcf->send_timeout = NGX_CONF_UNSET_MSEC;
35013513
clcf->send_lowat = NGX_CONF_UNSET_SIZE;
35023514
clcf->postpone_output = NGX_CONF_UNSET_SIZE;
3515+
clcf->keepalive_time = NGX_CONF_UNSET_MSEC;
35033516
clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
35043517
clcf->keepalive_header = NGX_CONF_UNSET;
35053518
clcf->keepalive_requests = NGX_CONF_UNSET_UINT;
@@ -3738,12 +3751,14 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
37383751
conf->limit_rate_after = prev->limit_rate_after;
37393752
}
37403753

3754+
ngx_conf_merge_msec_value(conf->keepalive_time,
3755+
prev->keepalive_time, 3600000);
37413756
ngx_conf_merge_msec_value(conf->keepalive_timeout,
37423757
prev->keepalive_timeout, 75000);
37433758
ngx_conf_merge_sec_value(conf->keepalive_header,
37443759
prev->keepalive_header, 0);
37453760
ngx_conf_merge_uint_value(conf->keepalive_requests,
3746-
prev->keepalive_requests, 100);
3761+
prev->keepalive_requests, 1000);
37473762
ngx_conf_merge_uint_value(conf->lingering_close,
37483763
prev->lingering_close, NGX_HTTP_LINGERING_ON);
37493764
ngx_conf_merge_msec_value(conf->lingering_time,

src/http/ngx_http_core_module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ struct ngx_http_core_loc_conf_s {
359359

360360
ngx_msec_t client_body_timeout; /* client_body_timeout */
361361
ngx_msec_t send_timeout; /* send_timeout */
362+
ngx_msec_t keepalive_time; /* keepalive_time */
362363
ngx_msec_t keepalive_timeout; /* keepalive_timeout */
363364
ngx_msec_t lingering_time; /* lingering_time */
364365
ngx_msec_t lingering_timeout; /* lingering_timeout */

src/http/ngx_http_variables.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ static ngx_int_t ngx_http_variable_connection(ngx_http_request_t *r,
129129
ngx_http_variable_value_t *v, uintptr_t data);
130130
static ngx_int_t ngx_http_variable_connection_requests(ngx_http_request_t *r,
131131
ngx_http_variable_value_t *v, uintptr_t data);
132+
static ngx_int_t ngx_http_variable_connection_time(ngx_http_request_t *r,
133+
ngx_http_variable_value_t *v, uintptr_t data);
132134

133135
static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
134136
ngx_http_variable_value_t *v, uintptr_t data);
@@ -342,6 +344,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
342344
{ ngx_string("connection_requests"), NULL,
343345
ngx_http_variable_connection_requests, 0, 0, 0 },
344346

347+
{ ngx_string("connection_time"), NULL, ngx_http_variable_connection_time,
348+
0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
349+
345350
{ ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
346351
0, 0, 0 },
347352

@@ -2252,6 +2257,31 @@ ngx_http_variable_connection_requests(ngx_http_request_t *r,
22522257
}
22532258

22542259

2260+
static ngx_int_t
2261+
ngx_http_variable_connection_time(ngx_http_request_t *r,
2262+
ngx_http_variable_value_t *v, uintptr_t data)
2263+
{
2264+
u_char *p;
2265+
ngx_msec_int_t ms;
2266+
2267+
p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4);
2268+
if (p == NULL) {
2269+
return NGX_ERROR;
2270+
}
2271+
2272+
ms = ngx_current_msec - r->connection->start_time;
2273+
ms = ngx_max(ms, 0);
2274+
2275+
v->len = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000) - p;
2276+
v->valid = 1;
2277+
v->no_cacheable = 0;
2278+
v->not_found = 0;
2279+
v->data = p;
2280+
2281+
return NGX_OK;
2282+
}
2283+
2284+
22552285
static ngx_int_t
22562286
ngx_http_variable_nginx_version(ngx_http_request_t *r,
22572287
ngx_http_variable_value_t *v, uintptr_t data)

0 commit comments

Comments
 (0)