Skip to content

Commit 9a11306

Browse files
nginxkolbyjack
nginx
authored andcommitted
Changes with nginx 1.7.7 28 Oct 2014
*) Change: now nginx takes into account the "Vary" header line in a backend response while caching. *) Feature: the "proxy_force_ranges", "fastcgi_force_ranges", "scgi_force_ranges", and "uwsgi_force_ranges" directives. *) Feature: the "proxy_limit_rate", "fastcgi_limit_rate", "scgi_limit_rate", and "uwsgi_limit_rate" directives. *) Feature: the "Vary" parameter of the "proxy_ignore_headers", "fastcgi_ignore_headers", "scgi_ignore_headers", and "uwsgi_ignore_headers" directives. *) Bugfix: the last part of a response received from a backend with unbufferred proxy might not be sent to a client if "gzip" or "gunzip" directives were used. *) Bugfix: in the "proxy_cache_revalidate" directive. Thanks to Piotr Sikora. *) Bugfix: in error handling. Thanks to Yichun Zhang and Daniil Bondarev. *) Bugfix: in the "proxy_next_upstream_tries" and "proxy_next_upstream_timeout" directives. Thanks to Feng Gu. *) Bugfix: nginx/Windows could not be built with MinGW-w64 gcc. Thanks to Kouhei Sutou.
1 parent 4aeefe1 commit 9a11306

28 files changed

+662
-36
lines changed

CHANGES

+33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
11

2+
Changes with nginx 1.7.7 28 Oct 2014
3+
4+
*) Change: now nginx takes into account the "Vary" header line in a
5+
backend response while caching.
6+
7+
*) Feature: the "proxy_force_ranges", "fastcgi_force_ranges",
8+
"scgi_force_ranges", and "uwsgi_force_ranges" directives.
9+
10+
*) Feature: the "proxy_limit_rate", "fastcgi_limit_rate",
11+
"scgi_limit_rate", and "uwsgi_limit_rate" directives.
12+
13+
*) Feature: the "Vary" parameter of the "proxy_ignore_headers",
14+
"fastcgi_ignore_headers", "scgi_ignore_headers", and
15+
"uwsgi_ignore_headers" directives.
16+
17+
*) Bugfix: the last part of a response received from a backend with
18+
unbufferred proxy might not be sent to a client if "gzip" or "gunzip"
19+
directives were used.
20+
21+
*) Bugfix: in the "proxy_cache_revalidate" directive.
22+
Thanks to Piotr Sikora.
23+
24+
*) Bugfix: in error handling.
25+
Thanks to Yichun Zhang and Daniil Bondarev.
26+
27+
*) Bugfix: in the "proxy_next_upstream_tries" and
28+
"proxy_next_upstream_timeout" directives.
29+
Thanks to Feng Gu.
30+
31+
*) Bugfix: nginx/Windows could not be built with MinGW-w64 gcc.
32+
Thanks to Kouhei Sutou.
33+
34+
235
Changes with nginx 1.7.6 30 Sep 2014
336

437
*) Change: the deprecated "limit_zone" directive is not supported

CHANGES.ru

+32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
11

2+
Изменения в nginx 1.7.7 28.10.2014
3+
4+
*) Изменение: теперь nginx учитывает при кэшировании строку "Vary" в
5+
заголовке ответа бэкенда.
6+
7+
*) Добавление: директивы proxy_force_ranges, fastcgi_force_ranges,
8+
scgi_force_ranges и uwsgi_force_ranges.
9+
10+
*) Добавление: директивы proxy_limit_rate, fastcgi_limit_rate,
11+
scgi_limit_rate и uwsgi_limit_rate.
12+
13+
*) Добавление: параметр Vary директив proxy_ignore_headers,
14+
fastcgi_ignore_headers, scgi_ignore_headers и uwsgi_ignore_headers.
15+
16+
*) Исправление: последняя часть ответа, полученного от бэкенда при
17+
небуферизированном проксировании, могла не отправляться клиенту, если
18+
использовались директивы gzip или gunzip.
19+
20+
*) Исправление: в директиве proxy_cache_revalidate.
21+
Спасибо Piotr Sikora.
22+
23+
*) Исправление: в обработке ошибок.
24+
Спасибо Yichun Zhang и Даниилу Бондареву.
25+
26+
*) Исправление: в директивах proxy_next_upstream_tries и
27+
proxy_next_upstream_timeout.
28+
Спасибо Feng Gu.
29+
30+
*) Исправление: nginx/Windows не собирался с MinGW-w64 gcc.
31+
Спасибо Kouhei Sutou.
32+
33+
234
Изменения в nginx 1.7.6 30.09.2014
335

436
*) Изменение: устаревшая директива limit_zone больше не поддерживается.

src/core/nginx.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define _NGINX_H_INCLUDED_
1010

1111

12-
#define nginx_version 1007006
13-
#define NGINX_VERSION "1.7.6"
12+
#define nginx_version 1007007
13+
#define NGINX_VERSION "1.7.7"
1414
#define NGINX_VER "nginx/" NGINX_VERSION
1515

1616
#ifdef NGX_BUILD

src/core/ngx_hash.c

+2
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, ngx_uint_t nelts)
312312
continue;
313313
}
314314

315+
size--;
316+
315317
ngx_log_error(NGX_LOG_WARN, hinit->pool->log, 0,
316318
"could not build optimal %s, you should increase "
317319
"either %s_max_size: %i or %s_bucket_size: %i; "

src/event/ngx_event_openssl.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,10 @@ ngx_ssl_handshake_handler(ngx_event_t *ev)
11851185

11861186

11871187
ssize_t
1188-
ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl)
1188+
ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit)
11891189
{
11901190
u_char *last;
1191-
ssize_t n, bytes;
1191+
ssize_t n, bytes, size;
11921192
ngx_buf_t *b;
11931193

11941194
bytes = 0;
@@ -1197,8 +1197,19 @@ ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl)
11971197
last = b->last;
11981198

11991199
for ( ;; ) {
1200+
size = b->end - last;
12001201

1201-
n = ngx_ssl_recv(c, last, b->end - last);
1202+
if (limit) {
1203+
if (bytes >= limit) {
1204+
return bytes;
1205+
}
1206+
1207+
if (bytes + size > limit) {
1208+
size = (ssize_t) (limit - bytes);
1209+
}
1210+
}
1211+
1212+
n = ngx_ssl_recv(c, last, size);
12021213

12031214
if (n > 0) {
12041215
last += n;

src/event/ngx_event_openssl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ ngx_int_t ngx_ssl_get_client_verify(ngx_connection_t *c, ngx_pool_t *pool,
194194
ngx_int_t ngx_ssl_handshake(ngx_connection_t *c);
195195
ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
196196
ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
197-
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
197+
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit);
198198
ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
199199
off_t limit);
200200
void ngx_ssl_free_buffer(ngx_connection_t *c);

src/event/ngx_event_pipe.c

+36-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
6666
return NGX_ABORT;
6767
}
6868

69-
if (rev->active && !rev->ready) {
70-
ngx_add_timer(rev, p->read_timeout);
69+
if (!rev->delayed) {
70+
if (rev->active && !rev->ready) {
71+
ngx_add_timer(rev, p->read_timeout);
7172

72-
} else if (rev->timer_set) {
73-
ngx_del_timer(rev);
73+
} else if (rev->timer_set) {
74+
ngx_del_timer(rev);
75+
}
7476
}
7577
}
7678

@@ -99,9 +101,11 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
99101
static ngx_int_t
100102
ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
101103
{
104+
off_t limit;
102105
ssize_t n, size;
103106
ngx_int_t rc;
104107
ngx_buf_t *b;
108+
ngx_msec_t delay;
105109
ngx_chain_t *chain, *cl, *ln;
106110

107111
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
@@ -169,6 +173,25 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
169173
}
170174
#endif
171175

176+
if (p->limit_rate) {
177+
if (p->upstream->read->delayed) {
178+
break;
179+
}
180+
181+
limit = (off_t) p->limit_rate * (ngx_time() - p->start_sec + 1)
182+
- p->read_length;
183+
184+
if (limit <= 0) {
185+
p->upstream->read->delayed = 1;
186+
delay = (ngx_msec_t) (- limit * 1000 / p->limit_rate + 1);
187+
ngx_add_timer(p->upstream->read, delay);
188+
break;
189+
}
190+
191+
} else {
192+
limit = 0;
193+
}
194+
172195
if (p->free_raw_bufs) {
173196

174197
/* use the free bufs if they exist */
@@ -270,7 +293,7 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
270293
break;
271294
}
272295

273-
n = p->upstream->recv_chain(p->upstream, chain);
296+
n = p->upstream->recv_chain(p->upstream, chain, limit);
274297

275298
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
276299
"pipe recv chain: %z", n);
@@ -301,6 +324,8 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
301324
}
302325
}
303326

327+
delay = p->limit_rate ? (ngx_msec_t) n * 1000 / p->limit_rate : 0;
328+
304329
p->read_length += n;
305330
cl = chain;
306331
p->free_raw_bufs = NULL;
@@ -337,6 +362,12 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
337362
ln->next = p->free_raw_bufs;
338363
p->free_raw_bufs = cl;
339364
}
365+
366+
if (delay > 0) {
367+
p->upstream->read->delayed = 1;
368+
ngx_add_timer(p->upstream->read, delay);
369+
break;
370+
}
340371
}
341372

342373
#if (NGX_DEBUG)

src/event/ngx_event_pipe.h

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ struct ngx_event_pipe_s {
8080
size_t preread_size;
8181
ngx_buf_t *buf_to_file;
8282

83+
size_t limit_rate;
84+
time_t start_sec;
85+
8386
ngx_temp_file_t *temp_file;
8487

8588
/* STUB */ int num;

src/http/modules/ngx_http_fastcgi_module.c

+22
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,20 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
326326
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf),
327327
NULL },
328328

329+
{ ngx_string("fastcgi_force_ranges"),
330+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
331+
ngx_conf_set_flag_slot,
332+
NGX_HTTP_LOC_CONF_OFFSET,
333+
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.force_ranges),
334+
NULL },
335+
336+
{ ngx_string("fastcgi_limit_rate"),
337+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
338+
ngx_conf_set_size_slot,
339+
NGX_HTTP_LOC_CONF_OFFSET,
340+
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.limit_rate),
341+
NULL },
342+
329343
#if (NGX_HTTP_CACHE)
330344

331345
{ ngx_string("fastcgi_cache"),
@@ -2332,6 +2346,7 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
23322346
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
23332347
conf->upstream.buffering = NGX_CONF_UNSET;
23342348
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
2349+
conf->upstream.force_ranges = NGX_CONF_UNSET;
23352350

23362351
conf->upstream.local = NGX_CONF_UNSET_PTR;
23372352

@@ -2342,6 +2357,7 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
23422357

23432358
conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE;
23442359
conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE;
2360+
conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE;
23452361

23462362
conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
23472363
conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
@@ -2413,6 +2429,9 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
24132429
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
24142430
prev->upstream.ignore_client_abort, 0);
24152431

2432+
ngx_conf_merge_value(conf->upstream.force_ranges,
2433+
prev->upstream.force_ranges, 0);
2434+
24162435
ngx_conf_merge_ptr_value(conf->upstream.local,
24172436
prev->upstream.local, NULL);
24182437

@@ -2435,6 +2454,9 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
24352454
prev->upstream.buffer_size,
24362455
(size_t) ngx_pagesize);
24372456

2457+
ngx_conf_merge_size_value(conf->upstream.limit_rate,
2458+
prev->upstream.limit_rate, 0);
2459+
24382460

24392461
ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs,
24402462
8, ngx_pagesize);

src/http/modules/ngx_http_gunzip_filter_module.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static ngx_int_t
175175
ngx_http_gunzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
176176
{
177177
int rc;
178+
ngx_uint_t flush;
178179
ngx_chain_t *cl;
179180
ngx_http_gunzip_ctx_t *ctx;
180181

@@ -199,7 +200,7 @@ ngx_http_gunzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
199200
}
200201
}
201202

202-
if (ctx->nomem || in == NULL) {
203+
if (ctx->nomem) {
203204

204205
/* flush busy buffers */
205206

@@ -212,6 +213,10 @@ ngx_http_gunzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
212213
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &cl,
213214
(ngx_buf_tag_t) &ngx_http_gunzip_filter_module);
214215
ctx->nomem = 0;
216+
flush = 0;
217+
218+
} else {
219+
flush = ctx->busy ? 1 : 0;
215220
}
216221

217222
for ( ;; ) {
@@ -258,7 +263,7 @@ ngx_http_gunzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
258263
/* rc == NGX_AGAIN */
259264
}
260265

261-
if (ctx->out == NULL) {
266+
if (ctx->out == NULL && !flush) {
262267
return ctx->busy ? NGX_AGAIN : NGX_OK;
263268
}
264269

@@ -276,6 +281,7 @@ ngx_http_gunzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
276281
"gunzip out: %p", ctx->out);
277282

278283
ctx->nomem = 0;
284+
flush = 0;
279285

280286
if (ctx->done) {
281287
return rc;

src/http/modules/ngx_http_gzip_filter_module.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ static ngx_int_t
316316
ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
317317
{
318318
int rc;
319+
ngx_uint_t flush;
319320
ngx_chain_t *cl;
320321
ngx_http_gzip_ctx_t *ctx;
321322

@@ -372,7 +373,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
372373
r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED;
373374
}
374375

375-
if (ctx->nomem || in == NULL) {
376+
if (ctx->nomem) {
376377

377378
/* flush busy buffers */
378379

@@ -385,6 +386,10 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
385386
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &cl,
386387
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
387388
ctx->nomem = 0;
389+
flush = 0;
390+
391+
} else {
392+
flush = ctx->busy ? 1 : 0;
388393
}
389394

390395
for ( ;; ) {
@@ -432,7 +437,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
432437
/* rc == NGX_AGAIN */
433438
}
434439

435-
if (ctx->out == NULL) {
440+
if (ctx->out == NULL && !flush) {
436441
ngx_http_gzip_filter_free_copy_buf(r, ctx);
437442

438443
return ctx->busy ? NGX_AGAIN : NGX_OK;
@@ -457,6 +462,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
457462
ctx->last_out = &ctx->out;
458463

459464
ctx->nomem = 0;
465+
flush = 0;
460466

461467
if (ctx->done) {
462468
return rc;

0 commit comments

Comments
 (0)