comparison src/http/v2/ngx_http_v2.c @ 7022:645ed7112a01

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@google.com>
author Piotr Sikora <piotrsikora@google.com>
date Fri, 02 Jun 2017 15:05:20 +0300
parents ab6ef3037840
children 859d80f57aab
comparison
equal deleted inserted replaced
7021:639e48c382a6 7022:645ed7112a01
1967 1967
1968 static u_char * 1968 static u_char *
1969 ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos, 1969 ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos,
1970 u_char *end) 1970 u_char *end)
1971 { 1971 {
1972 ssize_t window_delta;
1972 ngx_uint_t id, value; 1973 ngx_uint_t id, value;
1974
1975 window_delta = 0;
1973 1976
1974 while (h2c->state.length) { 1977 while (h2c->state.length) {
1975 if (end - pos < NGX_HTTP_V2_SETTINGS_PARAM_SIZE) { 1978 if (end - pos < NGX_HTTP_V2_SETTINGS_PARAM_SIZE) {
1976 return ngx_http_v2_state_save(h2c, pos, end, 1979 return ngx_http_v2_state_save(h2c, pos, end,
1977 ngx_http_v2_state_settings_params); 1980 ngx_http_v2_state_settings_params);
1993 1996
1994 return ngx_http_v2_connection_error(h2c, 1997 return ngx_http_v2_connection_error(h2c,
1995 NGX_HTTP_V2_FLOW_CTRL_ERROR); 1998 NGX_HTTP_V2_FLOW_CTRL_ERROR);
1996 } 1999 }
1997 2000
1998 if (ngx_http_v2_adjust_windows(h2c, value - h2c->init_window) 2001 window_delta = value - h2c->init_window;
1999 != NGX_OK)
2000 {
2001 return ngx_http_v2_connection_error(h2c,
2002 NGX_HTTP_V2_INTERNAL_ERROR);
2003 }
2004 2002
2005 h2c->init_window = value; 2003 h2c->init_window = value;
2006 break; 2004 break;
2007 2005
2008 case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING: 2006 case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING:
2024 default: 2022 default:
2025 break; 2023 break;
2026 } 2024 }
2027 2025
2028 pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE; 2026 pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE;
2027 }
2028
2029 if (window_delta) {
2030 if (ngx_http_v2_adjust_windows(h2c, window_delta) != NGX_OK) {
2031 return ngx_http_v2_connection_error(h2c,
2032 NGX_HTTP_V2_INTERNAL_ERROR);
2033 }
2029 } 2034 }
2030 2035
2031 return ngx_http_v2_state_complete(h2c, pos, end); 2036 return ngx_http_v2_state_complete(h2c, pos, end);
2032 } 2037 }
2033 2038