diff --git a/lib/http2/http2.c b/lib/http2/http2.c index 4f341449..b935637b 100644 --- a/lib/http2/http2.c +++ b/lib/http2/http2.c @@ -810,22 +810,33 @@ lws_h2_parse_frame_header(struct lws *wsi) if (!h2n->swsi) break; + /* account for both network and stream wsi windows */ + + wsi->h2.peer_tx_cr_est -= h2n->length; h2n->swsi->h2.peer_tx_cr_est -= h2n->length; - lwsl_debug(" peer_tx_cr_est %d\n", - h2n->swsi->h2.peer_tx_cr_est); - if (h2n->swsi->h2.peer_tx_cr_est < (int32_t)h2n->length + 265536) { - h2n->swsi->h2.peer_tx_cr_est += h2n->length + 265536; + + lwsl_debug(" peer_tx_cr_est %d, parent %d\n", + h2n->swsi->h2.peer_tx_cr_est, wsi->h2.peer_tx_cr_est); + + if (h2n->swsi->h2.peer_tx_cr_est < (int)(2 * h2n->length) + 65536) { pps = lws_h2_new_pps(LWS_H2_PPS_UPDATE_WINDOW); if (!pps) return 1; pps->u.update_window.sid = h2n->sid; - pps->u.update_window.credit = h2n->length + 265536; + pps->u.update_window.credit = (2 * h2n->length) + 65536; + h2n->swsi->h2.peer_tx_cr_est += pps->u.update_window.credit; lws_pps_schedule(wsi, pps); pps = lws_h2_new_pps(LWS_H2_PPS_UPDATE_WINDOW); if (!pps) return 1; + } + if (wsi->h2.peer_tx_cr_est < (int)(2 * h2n->length) + 65536) { + pps = lws_h2_new_pps(LWS_H2_PPS_UPDATE_WINDOW); + if (!pps) + return 1; pps->u.update_window.sid = 0; - pps->u.update_window.credit = h2n->length + 265536; + pps->u.update_window.credit = (2 * h2n->length) + 65536; + wsi->h2.peer_tx_cr_est += pps->u.update_window.credit; lws_pps_schedule(wsi, pps); }