Welcome! Log In Create A New Profile

Advanced

[PATCH 3 of 4] HTTP/2: make SETTINGS ACK frame reusable

Piotr Sikora via nginx-devel
June 01, 2017 05:54PM
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1493067017 25200
# Mon Apr 24 13:50:17 2017 -0700
# Node ID e00ba13ce421685981db6a98831409a234cc1e62
# Parent d61e944f55e70a5a25c8a79bfc5c167b7f22d62e
HTTP/2: make SETTINGS ACK frame reusable.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r d61e944f55e7 -r e00ba13ce421 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -28,6 +28,7 @@
#define NGX_HTTP_V2_HTTP_1_1_REQUIRED 0xd

/* frame sizes */
+#define NGX_HTTP_V2_SETTINGS_ACK_SIZE 0
#define NGX_HTTP_V2_RST_STREAM_SIZE 4
#define NGX_HTTP_V2_PRIORITY_SIZE 5
#define NGX_HTTP_V2_PING_SIZE 8
@@ -128,8 +129,7 @@ static ngx_http_v2_node_t *ngx_http_v2_g
#define ngx_http_v2_index_size(h2scf) (h2scf->streams_index_mask + 1)
#define ngx_http_v2_index(h2scf, sid) ((sid >> 1) & h2scf->streams_index_mask)

-static ngx_int_t ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c,
- ngx_uint_t ack);
+static ngx_int_t ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c);
static ngx_int_t ngx_http_v2_settings_frame_handler(
ngx_http_v2_connection_t *h2c, ngx_http_v2_out_frame_t *frame);
static ngx_int_t ngx_http_v2_send_window_update(ngx_http_v2_connection_t *h2c,
@@ -269,7 +269,7 @@ ngx_http_v2_init(ngx_event_t *rev)
return;
}

- if (ngx_http_v2_send_settings(h2c, 0) == NGX_ERROR) {
+ if (ngx_http_v2_send_settings(h2c) == NGX_ERROR) {
ngx_http_close_connection(c);
return;
}
@@ -1967,8 +1967,9 @@ static u_char *
ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos,
u_char *end)
{
- ssize_t window_delta;
- ngx_uint_t id, value;
+ ssize_t window_delta;
+ ngx_uint_t id, value;
+ ngx_http_v2_out_frame_t *frame;

window_delta = 0;

@@ -2024,7 +2025,14 @@ ngx_http_v2_state_settings_params(ngx_ht
pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE;
}

- ngx_http_v2_send_settings(h2c, 1);
+ frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_SETTINGS_ACK_SIZE,
+ NGX_HTTP_V2_SETTINGS_FRAME,
+ NGX_HTTP_V2_ACK_FLAG, 0);
+ if (frame == NULL) {
+ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+
+ ngx_http_v2_queue_blocked_frame(h2c, frame);

if (window_delta) {
if (ngx_http_v2_adjust_windows(h2c, window_delta) != NGX_OK) {
@@ -2476,7 +2484,7 @@ ngx_http_v2_parse_int(ngx_http_v2_connec


static ngx_int_t
-ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c, ngx_uint_t ack)
+ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c)
{
size_t len;
ngx_buf_t *buf;
@@ -2484,8 +2492,8 @@ ngx_http_v2_send_settings(ngx_http_v2_co
ngx_http_v2_srv_conf_t *h2scf;
ngx_http_v2_out_frame_t *frame;

- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
- "http2 send SETTINGS frame ack:%ui", ack);
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
+ "http2 send SETTINGS frame");

frame = ngx_palloc(h2c->pool, sizeof(ngx_http_v2_out_frame_t));
if (frame == NULL) {
@@ -2497,7 +2505,7 @@ ngx_http_v2_send_settings(ngx_http_v2_co
return NGX_ERROR;
}

- len = ack ? 0 : (sizeof(uint16_t) + sizeof(uint32_t)) * 3;
+ len = NGX_HTTP_V2_SETTINGS_PARAM_SIZE * 3;

buf = ngx_create_temp_buf(h2c->pool, NGX_HTTP_V2_FRAME_HEADER_SIZE + len);
if (buf == NULL) {
@@ -2521,28 +2529,26 @@ ngx_http_v2_send_settings(ngx_http_v2_co
buf->last = ngx_http_v2_write_len_and_type(buf->last, len,
NGX_HTTP_V2_SETTINGS_FRAME);

- *buf->last++ = ack ? NGX_HTTP_V2_ACK_FLAG : NGX_HTTP_V2_NO_FLAG;
+ *buf->last++ = NGX_HTTP_V2_NO_FLAG;

buf->last = ngx_http_v2_write_sid(buf->last, 0);

- if (!ack) {
- h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
- ngx_http_v2_module);
-
- buf->last = ngx_http_v2_write_uint16(buf->last,
- NGX_HTTP_V2_MAX_STREAMS_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last,
- h2scf->concurrent_streams);
-
- buf->last = ngx_http_v2_write_uint16(buf->last,
+ h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
+ ngx_http_v2_module);
+
+ buf->last = ngx_http_v2_write_uint16(buf->last,
+ NGX_HTTP_V2_MAX_STREAMS_SETTING);
+ buf->last = ngx_http_v2_write_uint32(buf->last,
+ h2scf->concurrent_streams);
+
+ buf->last = ngx_http_v2_write_uint16(buf->last,
NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size);
-
- buf->last = ngx_http_v2_write_uint16(buf->last,
- NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last,
- NGX_HTTP_V2_MAX_FRAME_SIZE);
- }
+ buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size);
+
+ buf->last = ngx_http_v2_write_uint16(buf->last,
+ NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING);
+ buf->last = ngx_http_v2_write_uint32(buf->last,
+ NGX_HTTP_V2_MAX_FRAME_SIZE);

ngx_http_v2_queue_blocked_frame(h2c, frame);

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

[PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Piotr Sikora via nginx-devel 497 April 24, 2017 06:50PM

[PATCH 3 of 4] HTTP/2: make SETTINGS ACK frame reusable

Piotr Sikora via nginx-devel 231 April 24, 2017 06:50PM

Re: [PATCH 3 of 4] HTTP/2: make SETTINGS ACK frame reusable

Valentin V. Bartenev 167 June 01, 2017 01:54PM

[PATCH 2 of 4] HTTP/2: send SETTINGS ACK after applying all SETTINGS params

Piotr Sikora via nginx-devel 260 April 24, 2017 06:50PM

Re: [PATCH 2 of 4] HTTP/2: send SETTINGS ACK after applying all SETTINGS params

Valentin V. Bartenev 193 June 01, 2017 01:24PM

[PATCH 4 of 4] HTTP/2: don't send SETTINGS ACK before already queued DATA frames

Piotr Sikora via nginx-devel 231 April 24, 2017 06:50PM

Re: [PATCH 4 of 4] HTTP/2: don't send SETTINGS ACK before already queued DATA frames

Valentin V. Bartenev 232 June 01, 2017 01:54PM

Re: [PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Piotr Sikora via nginx-devel 236 May 30, 2017 05:24PM

Re: [PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Valentin V. Bartenev 189 June 01, 2017 10:50AM

Re: [PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Valentin V. Bartenev 189 June 01, 2017 01:56PM

Re: [PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Piotr Sikora via nginx-devel 188 June 01, 2017 05:56PM

Re: [PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Valentin V. Bartenev 349 June 02, 2017 08:12AM

[PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params

Piotr Sikora via nginx-devel 208 June 01, 2017 05:54PM

[PATCH 2 of 4] HTTP/2: send SETTINGS ACK after applying all SETTINGS params

Piotr Sikora via nginx-devel 213 June 01, 2017 05:54PM

[PATCH 3 of 4] HTTP/2: make SETTINGS ACK frame reusable

Piotr Sikora via nginx-devel 243 June 01, 2017 05:54PM

[PATCH 4 of 4] HTTP/2: don't send SETTINGS ACK before already queued DATA frames

Piotr Sikora via nginx-devel 197 June 01, 2017 05:54PM



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

Online Users

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