mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-09 19:31:06 +01:00
MEDIUM: h2: allocate and release the h2c context on connection init/end
The connection's h2c context is now allocated and initialized on mux initialization, and released on mux destruction. Note that for now the release() code is never called.
This commit is contained in:
parent
c64051404d
commit
32218eb344
64
src/mux_h2.c
64
src/mux_h2.c
@ -135,6 +135,50 @@ static int h2_settings_max_concurrent_streams = 100;
|
||||
/* functions below are dedicated to the mux setup and management */
|
||||
/*****************************************************************/
|
||||
|
||||
/* tries to initialize the inbound h2c mux. Returns < 0 in case of failure. */
|
||||
static int h2c_frt_init(struct connection *conn)
|
||||
{
|
||||
struct h2c *h2c;
|
||||
|
||||
h2c = pool_alloc2(pool2_h2c);
|
||||
if (!h2c)
|
||||
goto fail;
|
||||
|
||||
h2c->ddht = hpack_dht_alloc(h2_settings_header_table_size);
|
||||
if (!h2c->ddht)
|
||||
goto fail;
|
||||
|
||||
/* Initialise the context. */
|
||||
h2c->st0 = H2_CS_PREFACE;
|
||||
h2c->conn = conn;
|
||||
h2c->max_id = -1;
|
||||
h2c->errcode = H2_ERR_NO_ERROR;
|
||||
h2c->flags = H2_CF_NONE;
|
||||
h2c->rcvd_c = 0;
|
||||
h2c->rcvd_s = 0;
|
||||
|
||||
h2c->dbuf = &buf_empty;
|
||||
h2c->dsi = -1;
|
||||
h2c->msi = -1;
|
||||
h2c->last_sid = -1;
|
||||
|
||||
h2c->mbuf = &buf_empty;
|
||||
h2c->miw = 65535; /* mux initial window size */
|
||||
h2c->mws = 65535; /* mux window size */
|
||||
h2c->mfs = 16384; /* initial max frame size */
|
||||
h2c->streams_by_id = EB_ROOT_UNIQUE;
|
||||
LIST_INIT(&h2c->send_list);
|
||||
LIST_INIT(&h2c->fctl_list);
|
||||
conn->mux_ctx = h2c;
|
||||
|
||||
conn_xprt_want_recv(conn);
|
||||
/* mux->wake will be called soon to complete the operation */
|
||||
return 0;
|
||||
fail:
|
||||
pool_free2(pool2_h2c, h2c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize the mux once it's attached. For outgoing connections, the context
|
||||
* is already initialized before installing the mux, so we detect incoming
|
||||
* connections from the fact that the context is still NULL. Returns < 0 on
|
||||
@ -147,8 +191,7 @@ static int h2_init(struct connection *conn)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* not implemented yet */
|
||||
return -1;
|
||||
return h2c_frt_init(conn);
|
||||
}
|
||||
|
||||
/* release function for a connection. This one should be called to free all
|
||||
@ -156,6 +199,23 @@ static int h2_init(struct connection *conn)
|
||||
*/
|
||||
static void h2_release(struct connection *conn)
|
||||
{
|
||||
struct h2c *h2c = conn->mux_ctx;
|
||||
|
||||
LIST_DEL(&conn->list);
|
||||
|
||||
if (h2c) {
|
||||
hpack_dht_free(h2c->ddht);
|
||||
pool_free2(pool2_h2c, h2c);
|
||||
}
|
||||
|
||||
conn->mux = NULL;
|
||||
conn->mux_ctx = NULL;
|
||||
|
||||
conn_stop_tracking(conn);
|
||||
conn_full_close(conn);
|
||||
if (conn->destroy_cb)
|
||||
conn->destroy_cb(conn);
|
||||
conn_free(conn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user