diff --git a/lib/roles/h2/ops-h2.c b/lib/roles/h2/ops-h2.c index 804176a1a..a63520d44 100644 --- a/lib/roles/h2/ops-h2.c +++ b/lib/roles/h2/ops-h2.c @@ -296,12 +296,24 @@ drain: // lws_buflist_describe(&wsi->buflist, wsi); +#if 0 + + /* + * This seems to be too aggressive... we don't want the ah stuck + * there but eg, WINDOW_UPDATE may come and detach it if we leave + * it like that... it will get detached at stream close + */ + if (wsi->http.ah #if !defined(LWS_NO_CLIENT) && !wsi->client_h2_alpn #endif - ) + ) { + lwsl_err("xxx\n"); + lws_header_table_detach(wsi, 0); + } +#endif pending = lws_ssl_pending(wsi); if (pending) { @@ -1148,34 +1160,33 @@ rops_alpn_negotiated_h2(struct lws *wsi, const char *alpn) } #endif - wsi->upgraded_to_http2 = 1; - wsi->vhost->conn_stats.h2_alpn++; + wsi->upgraded_to_http2 = 1; + wsi->vhost->conn_stats.h2_alpn++; - /* adopt the header info */ + /* adopt the header info */ - ah = wsi->http.ah; + ah = wsi->http.ah; - lws_role_transition(wsi, LWSIFR_SERVER, LRS_H2_AWAIT_PREFACE, - &role_ops_h2); + lws_role_transition(wsi, LWSIFR_SERVER, LRS_H2_AWAIT_PREFACE, + &role_ops_h2); - /* http2 union member has http union struct at start */ - wsi->http.ah = ah; + /* http2 union member has http union struct at start */ + wsi->http.ah = ah; - if (!wsi->h2.h2n) - wsi->h2.h2n = lws_zalloc(sizeof(*wsi->h2.h2n), "h2n"); - if (!wsi->h2.h2n) - return 1; + if (!wsi->h2.h2n) + wsi->h2.h2n = lws_zalloc(sizeof(*wsi->h2.h2n), "h2n"); + if (!wsi->h2.h2n) + return 1; - lws_h2_init(wsi); + lws_h2_init(wsi); - /* HTTP2 union */ + /* HTTP2 union */ - lws_hpack_dynamic_size(wsi, - wsi->h2.h2n->set.s[H2SET_HEADER_TABLE_SIZE]); - wsi->h2.tx_cr = 65535; - - lwsl_info("%s: wsi %p: configured for h2\n", __func__, wsi); + lws_hpack_dynamic_size(wsi, + wsi->h2.h2n->set.s[H2SET_HEADER_TABLE_SIZE]); + wsi->h2.tx_cr = 65535; + lwsl_info("%s: wsi %p: configured for h2\n", __func__, wsi); return 0; } diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index 434648521..6ec3c57cb 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -1812,6 +1812,7 @@ int lws_handshake_server(struct lws *wsi, unsigned char **buf, size_t len) { struct lws_context *context = lws_get_context(wsi); + struct allocated_headers *ah; unsigned char *obuf = *buf; #if defined(LWS_WITH_HTTP2) char tbuf[128], *p; @@ -2045,8 +2046,17 @@ upgrade_h2c: return 1; } + wsi->upgraded_to_http2 = 1; + /* adopt the header info */ + ah = wsi->http.ah; + lws_role_transition(wsi, LWSIFR_SERVER, LRS_H2_AWAIT_PREFACE, + &role_ops_h2); + + /* http2 union member has http union struct at start */ + wsi->http.ah = ah; + if (!wsi->h2.h2n) { wsi->h2.h2n = lws_zalloc(sizeof(*wsi->h2.h2n), "h2n"); @@ -2073,9 +2083,6 @@ upgrade_h2c: return 1; } - lwsi_set_state(wsi, LRS_H2_AWAIT_PREFACE); - wsi->upgraded_to_http2 = 1; - return 0; #endif #if defined(LWS_ROLE_WS)