mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-02 16:21:27 +01:00
MINOR: h1: h1_release() should return if it destroyed the connection
h1_release() is called to destroy everything related to the mux h1, usually even the connection. However, it handles upgrades to HTTP/2 too, in which case the h1 mux will be destroyed, but the connection will still be alive. So make it so it returns 0 if everything is destroyed, and -1 if the connection is still alive. This should be backported up to 2.8, as a future bugfix will depend on it.
This commit is contained in:
parent
14a333c4f4
commit
2f8f09854f
@ -339,7 +339,7 @@ DECLARE_STATIC_TYPED_POOL(pool_head_h1s, "h1s", struct h1s);
|
|||||||
static int h1_recv(struct h1c *h1c);
|
static int h1_recv(struct h1c *h1c);
|
||||||
static int h1_send(struct h1c *h1c);
|
static int h1_send(struct h1c *h1c);
|
||||||
static int h1_process(struct h1c *h1c);
|
static int h1_process(struct h1c *h1c);
|
||||||
static void h1_release(struct h1c *h1c);
|
static int h1_release(struct h1c *h1c);
|
||||||
|
|
||||||
/* h1_io_cb is exported to see it resolved in "show fd" */
|
/* h1_io_cb is exported to see it resolved in "show fd" */
|
||||||
struct task *h1_io_cb(struct task *t, void *ctx, unsigned int state);
|
struct task *h1_io_cb(struct task *t, void *ctx, unsigned int state);
|
||||||
@ -1371,8 +1371,10 @@ static int h1_init(struct connection *conn, struct proxy *proxy, struct session
|
|||||||
|
|
||||||
/* release function. This one should be called to free all resources allocated
|
/* release function. This one should be called to free all resources allocated
|
||||||
* to the mux.
|
* to the mux.
|
||||||
|
* Returns 0 if everything was destroyed, -1 if an upgrade to h2 happened
|
||||||
|
* and the connection is still alive.
|
||||||
*/
|
*/
|
||||||
static void h1_release(struct h1c *h1c)
|
static int h1_release(struct h1c *h1c)
|
||||||
{
|
{
|
||||||
struct connection *conn = NULL;
|
struct connection *conn = NULL;
|
||||||
|
|
||||||
@ -1391,7 +1393,7 @@ static void h1_release(struct h1c *h1c)
|
|||||||
if (conn_upgrade_mux_fe(conn, NULL, &h1c->ibuf, ist("h2"), PROTO_MODE_HTTP) != -1) {
|
if (conn_upgrade_mux_fe(conn, NULL, &h1c->ibuf, ist("h2"), PROTO_MODE_HTTP) != -1) {
|
||||||
/* connection successfully upgraded to H2, this
|
/* connection successfully upgraded to H2, this
|
||||||
* mux was already released */
|
* mux was already released */
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
TRACE_ERROR("h2 upgrade failed", H1_EV_H1C_END|H1_EV_H1C_ERR, conn);
|
TRACE_ERROR("h2 upgrade failed", H1_EV_H1C_END|H1_EV_H1C_ERR, conn);
|
||||||
sess_log(conn->owner); /* Log if the upgrade failed */
|
sess_log(conn->owner); /* Log if the upgrade failed */
|
||||||
@ -1437,6 +1439,7 @@ static void h1_release(struct h1c *h1c)
|
|||||||
conn->destroy_cb(conn);
|
conn->destroy_cb(conn);
|
||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************/
|
/******************************************************/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user