[PATCH 1 of 4] HTTP/2: emit new frames only after applying all SETTINGS params
Piotr Sikora
piotrsikora at google.com
Mon Apr 24 22:48:23 UTC 2017
# HG changeset patch
# User Piotr Sikora <piotrsikora at google.com>
# Date 1493073310 25200
# Mon Apr 24 15:35:10 2017 -0700
# Node ID 07adf0a7009c3244de4b795c0c06927f4316a87f
# Parent 2c4dbcd6f2e4c9c2a1eb8dc1f0d39c99975ae208
HTTP/2: emit new frames only after applying all SETTINGS params.
Previously, new frames could be emitted in the middle of applying
new (and already acknowledged) SETTINGS params, which is illegal.
Signed-off-by: Piotr Sikora <piotrsikora at google.com>
diff -r 2c4dbcd6f2e4 -r 07adf0a7009c src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -1982,7 +1982,9 @@ static u_char *
ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos,
u_char *end)
{
- ngx_uint_t id, value;
+ ngx_uint_t id, value, adjustment;
+
+ adjustment = 0;
while (h2c->state.length) {
if (end - pos < NGX_HTTP_V2_SETTINGS_PARAM_SIZE) {
@@ -2008,13 +2010,7 @@ ngx_http_v2_state_settings_params(ngx_ht
NGX_HTTP_V2_FLOW_CTRL_ERROR);
}
- if (ngx_http_v2_adjust_windows(h2c, value - h2c->init_window)
- != NGX_OK)
- {
- return ngx_http_v2_connection_error(h2c,
- NGX_HTTP_V2_INTERNAL_ERROR);
- }
-
+ adjustment = value - h2c->init_window;
h2c->init_window = value;
break;
@@ -2041,6 +2037,13 @@ ngx_http_v2_state_settings_params(ngx_ht
pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE;
}
+ if (adjustment) {
+ if (ngx_http_v2_adjust_windows(h2c, adjustment) != NGX_OK) {
+ return ngx_http_v2_connection_error(h2c,
+ NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+ }
+
return ngx_http_v2_state_complete(h2c, pos, end);
}
More information about the nginx-devel
mailing list