mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-24 07:11:20 +02:00
MINOR: mux: Add a destroy() method.
Add a new method to muxes, destroy(), that is responsible for destroying the mux and the associated connection, to be used for server connections.
This commit is contained in:
parent
d540b36e8a
commit
060ed43361
@ -327,6 +327,7 @@ struct mux_ops {
|
|||||||
int (*subscribe)(struct conn_stream *cs, int event_type, void *param); /* Subscribe to events, such as "being able to send" */
|
int (*subscribe)(struct conn_stream *cs, int event_type, void *param); /* Subscribe to events, such as "being able to send" */
|
||||||
int (*unsubscribe)(struct conn_stream *cs, int event_type, void *param); /* Unsubscribe to events */
|
int (*unsubscribe)(struct conn_stream *cs, int event_type, void *param); /* Unsubscribe to events */
|
||||||
int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */
|
int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */
|
||||||
|
void (*destroy)(struct connection *conn); /* Let the mux know one of its users left, so it may have to disappear */
|
||||||
unsigned int flags; /* some flags characterizing the mux's capabilities (MX_FL_*) */
|
unsigned int flags; /* some flags characterizing the mux's capabilities (MX_FL_*) */
|
||||||
char name[8]; /* mux layer name, zero-terminated */
|
char name[8]; /* mux layer name, zero-terminated */
|
||||||
};
|
};
|
||||||
|
13
src/mux_h2.c
13
src/mux_h2.c
@ -2478,7 +2478,6 @@ static int h2_wake(struct connection *conn)
|
|||||||
return (h2_process(h2c));
|
return (h2_process(h2c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Connection timeout management. The principle is that if there's no receipt
|
/* Connection timeout management. The principle is that if there's no receipt
|
||||||
* nor sending for a certain amount of time, the connection is closed. If the
|
* nor sending for a certain amount of time, the connection is closed. If the
|
||||||
* MUX buffer still has lying data or is not allocatable, the connection is
|
* MUX buffer still has lying data or is not allocatable, the connection is
|
||||||
@ -2567,6 +2566,17 @@ static const struct conn_stream *h2_get_first_cs(const struct connection *conn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy the mux and the associated connection, if it is no longer used
|
||||||
|
*/
|
||||||
|
static void h2_destroy(struct connection *conn)
|
||||||
|
{
|
||||||
|
struct h2c *h2c = conn->mux_ctx;
|
||||||
|
|
||||||
|
if (eb_is_empty(&h2c->streams_by_id))
|
||||||
|
h2_release(h2c->conn);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach the stream from the connection and possibly release the connection.
|
* Detach the stream from the connection and possibly release the connection.
|
||||||
*/
|
*/
|
||||||
@ -3800,6 +3810,7 @@ const struct mux_ops h2_ops = {
|
|||||||
.attach = h2_attach,
|
.attach = h2_attach,
|
||||||
.get_first_cs = h2_get_first_cs,
|
.get_first_cs = h2_get_first_cs,
|
||||||
.detach = h2_detach,
|
.detach = h2_detach,
|
||||||
|
.destroy = h2_destroy,
|
||||||
.avail_streams = h2_avail_streams,
|
.avail_streams = h2_avail_streams,
|
||||||
.shutr = h2_shutr,
|
.shutr = h2_shutr,
|
||||||
.shutw = h2_shutw,
|
.shutw = h2_shutw,
|
||||||
|
@ -149,6 +149,12 @@ static const struct conn_stream *mux_pt_get_first_cs(const struct connection *co
|
|||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the mux and the associated connection */
|
||||||
|
static void mux_pt_destroy_meth(struct connection *conn)
|
||||||
|
{
|
||||||
|
mux_pt_destroy(conn->mux_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach the stream from the connection and possibly release the connection.
|
* Detach the stream from the connection and possibly release the connection.
|
||||||
*/
|
*/
|
||||||
@ -269,6 +275,7 @@ const struct mux_ops mux_pt_ops = {
|
|||||||
.get_first_cs = mux_pt_get_first_cs,
|
.get_first_cs = mux_pt_get_first_cs,
|
||||||
.detach = mux_pt_detach,
|
.detach = mux_pt_detach,
|
||||||
.avail_streams = mux_pt_avail_streams,
|
.avail_streams = mux_pt_avail_streams,
|
||||||
|
.destroy = mux_pt_destroy_meth,
|
||||||
.shutr = mux_pt_shutr,
|
.shutr = mux_pt_shutr,
|
||||||
.shutw = mux_pt_shutw,
|
.shutw = mux_pt_shutw,
|
||||||
.flags = MX_FL_NONE,
|
.flags = MX_FL_NONE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user