Welcome! Log In Create A New Profile

Advanced

[nginx] Range filter: fixed duplicate last buffers.

Maxim Dounin
May 13, 2019 05:22PM
details: https://hg.nginx.org/nginx/rev/c30a20e06c21
branches:
changeset: 7508:c30a20e06c21
user: Maxim Dounin <mdounin@mdounin.ru>
date: Mon May 13 22:44:49 2019 +0300
description:
Range filter: fixed duplicate last buffers.

In ngx_http_range_singlepart_body() special buffers where passed
unmodified, including ones after the end of the range. As such,
if the last buffer of a response was sent separately as a special
buffer, two buffers with b->last_buf set were present in the response.

In particular, this might result in a duplicate final chunk when using
chunked transfer encoding (normally range filter and chunked transfer
encoding are not used together, but this may happen if there are trailers
in the response). This also likely to cause problems in HTTP/2.

Fix is to skip all special buffers after we've sent the last part of
the range requested. These special buffers are not meaningful anyway,
since we set b->last_buf in the buffer with the last part of the range,
and everything is expected to be flushed due to it.

Additionally, ngx_http_next_body_filter() is now called even
if no buffers are to be passed to it. This ensures that various
write events are properly propagated through the filter chain. In
particular, this fixes test failures observed with the above change
and aio enabled.

diffstat:

src/http/modules/ngx_http_range_filter_module.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diffs (25 lines):

diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -723,6 +723,10 @@ ngx_http_range_singlepart_body(ngx_http_

if (ngx_buf_special(buf)) {

+ if (range->end <= start) {
+ continue;
+ }
+
tl = ngx_alloc_chain_link(r->pool);
if (tl == NULL) {
return NGX_ERROR;
@@ -802,10 +806,6 @@ ngx_http_range_singlepart_body(ngx_http_
ll = &tl->next;
}

- if (out == NULL) {
- return NGX_OK;
- }
-
rc = ngx_http_next_body_filter(r, out);

while (out) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Range filter: fixed duplicate last buffers.

Maxim Dounin 356 May 13, 2019 05:22PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready