Welcome! Log In Create A New Profile

Advanced

[nginx] HTTP/2: fixed handling of output HEADERS frames.

Valentin Bartenev
November 13, 2015 12:12PM
details: http://hg.nginx.org/nginx/rev/f72d3129cd35
branches:
changeset: 6292:f72d3129cd35
user: Valentin Bartenev <vbart@nginx.com>
date: Fri Nov 13 20:10:50 2015 +0300
description:
HTTP/2: fixed handling of output HEADERS frames.

The HEADERS frame is always represented by more than one buffer since
b930e598a199, but the handling code hasn't been adjusted.

Only the first buffer of HEADERS frame was checked and if it had been
sent while others had not, the rest of the frame was dropped, resulting
in broken connection.

Before b930e598a199, the problem could only be seen in case of HEADERS
frame with CONTINUATION.

diffstat:

src/http/v2/ngx_http_v2_filter_module.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r 932a465537ef -r f72d3129cd35 src/http/v2/ngx_http_v2_filter_module.c
--- a/src/http/v2/ngx_http_v2_filter_module.c Fri Nov 13 20:10:50 2015 +0300
+++ b/src/http/v2/ngx_http_v2_filter_module.c Fri Nov 13 20:10:50 2015 +0300
@@ -1054,17 +1054,30 @@ static ngx_int_t
ngx_http_v2_headers_frame_handler(ngx_http_v2_connection_t *h2c,
ngx_http_v2_out_frame_t *frame)
{
- ngx_buf_t *buf;
+ ngx_chain_t *cl;
ngx_http_v2_stream_t *stream;

- buf = frame->first->buf;
+ stream = frame->stream;
+ cl = frame->first;

- if (buf->pos != buf->last) {
- return NGX_AGAIN;
+ for ( ;; ) {
+ if (cl->buf->pos != cl->buf->last) {
+ frame->first = cl;
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
+ "http2:%ui HEADERS frame %p was sent partially",
+ stream->node->id, frame);
+
+ return NGX_AGAIN;
+ }
+
+ if (cl == frame->last) {
+ break;
+ }
+
+ cl = cl->next;
}

- stream = frame->stream;
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
"http2:%ui HEADERS frame %p was sent",
stream->node->id, frame);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] HTTP/2: fixed handling of output HEADERS frames.

Valentin Bartenev 369 November 13, 2015 12:12PM



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

Online Users

Guests: 275
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