Respect peer setting's initial window size
https://github.com/h2o/h2o/blob/master/lib/common/http2client.c#L771C1-L771C96
peer_settings.initial_window_size
A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available space in a flow-control window to become negative. A sender MUST track the negative flow-control window and MUST NOT send new flow-controlled frames until it receives WINDOW_UPDATE frames that cause the flow-control window to become positive.
For example, if the client sends 60 KB immediately on connection establishment and the server sets the initial window size to be 16 KB, the client will recalculate the available flow-control window to be -44 KB on receipt of the SETTINGS frame. The client retains a negative flow-control window until WINDOW_UPDATE frames restore the window to being positive, after which the client can resume sending.
should it be fixed as the following?
--- a/lib/common/http2client.c
+++ b/lib/common/http2client.c
@@ -756,7 +756,7 @@ static int handle_settings_frame(struct st_h2o_http2client_conn_t *conn, h2o_htt
return H2O_HTTP2_ERROR_FRAME_SIZE;
}
} else {
- uint32_t prev_initial_window_size = conn->peer_settings.initial_window_size;
+ ssize_t prev_initial_window_size = conn->peer_settings.initial_window_size;
int ret = h2o_http2_update_peer_settings(&conn->peer_settings, frame->payload, frame->length, err_desc);
if (ret != 0)
return ret;
@@ -768,7 +768,7 @@ static int handle_settings_frame(struct st_h2o_http2client_conn_t *conn, h2o_htt
}
/* apply the change to window size (to all the streams but not the connection, see 6.9.2 of draft-15) */
if (prev_initial_window_size != conn->peer_settings.initial_window_size) {
- ssize_t delta = conn->peer_settings.initial_window_size - prev_initial_window_size;
+ ssize_t delta = (ssize_t)conn->peer_settings.initial_window_size - prev_initial_window_size;
struct st_h2o_http2client_stream_t *stream;
kh_foreach_value(conn->streams, stream, { update_stream_output_window((void *)stream, delta); });Source: h2o/h2o