mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-13 06:54:37 +00:00
MEDIUM: connection: add a destroy callback
This callback will be used to release upper layers when a mux is in use. Given that the mux can be asynchronously deleted, we need a way to release the extra information such as the session. This callback will be called directly by the mux upon releasing everything and before the connection itself is released, so that the callee can find its information inside the connection if needed. The way it currently works is not perfect, and most likely this should instead become a mux release callback, but for now we have no easy way to add mux-specific stuff, and since there's one mux per connection, it works fine this way.
This commit is contained in:
parent
ac59f361ba
commit
436d333124
@ -615,14 +615,16 @@ static inline void conn_init(struct connection *conn)
|
||||
conn->err_code = CO_ER_NONE;
|
||||
conn->target = NULL;
|
||||
conn->xprt_done_cb = NULL;
|
||||
conn->destroy_cb = NULL;
|
||||
conn->proxy_netns = NULL;
|
||||
LIST_INIT(&conn->list);
|
||||
}
|
||||
|
||||
/* sets <owner> as the connection's owner */
|
||||
static inline void conn_set_owner(struct connection *conn, void *owner)
|
||||
static inline void conn_set_owner(struct connection *conn, void *owner, void (*cb)(struct connection *))
|
||||
{
|
||||
conn->owner = owner;
|
||||
conn->destroy_cb = cb;
|
||||
}
|
||||
|
||||
/* registers <cb> as a callback to notify for transport's readiness or failure */
|
||||
|
@ -377,6 +377,7 @@ struct connection {
|
||||
enum obj_type *target; /* the target to connect to (server, proxy, applet, ...) */
|
||||
struct list list; /* attach point to various connection lists (idle, ...) */
|
||||
int (*xprt_done_cb)(struct connection *conn); /* callback to notify of end of handshake */
|
||||
void (*destroy_cb)(struct connection *conn); /* callback to notify of imminent death of the connection */
|
||||
const struct netns_entry *proxy_netns;
|
||||
struct {
|
||||
struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */
|
||||
|
@ -122,6 +122,8 @@ static void mux_pt_detach(struct conn_stream *cs)
|
||||
LIST_DEL(&conn->list);
|
||||
conn_stop_tracking(conn);
|
||||
conn_full_close(conn);
|
||||
if (conn->destroy_cb)
|
||||
conn->destroy_cb(conn);
|
||||
conn_free(conn);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
|
||||
if (!sess)
|
||||
goto out_free_conn;
|
||||
|
||||
conn_set_owner(cli_conn, sess);
|
||||
conn_set_owner(cli_conn, sess, NULL);
|
||||
|
||||
/* now evaluate the tcp-request layer4 rules. We only need a session
|
||||
* and no stream for these rules.
|
||||
|
Loading…
Reference in New Issue
Block a user