mirror of
https://github.com/haproxy/haproxy.git
synced 2026-06-10 17:32:03 -04:00
BUG/MINOR: prevent conn leak in case of xprt_qmux init failure
In case of XPRT_QMUX init failure on the frontend side, the connection must immediately be released. This is not the case on the backend side as a stream can supervize the connection lifetime. This patch performs the connection free via conn_complete_session(). As conn is flagged with CO_FL_ERROR, this will automatically fail and invoke session_kill_embryonic(), which ensures the session and its connection are both freed as wanted in this case. No need to backport.
This commit is contained in:
parent
de3f245df0
commit
f521581922
1 changed files with 11 additions and 3 deletions
|
|
@ -6977,16 +6977,24 @@ struct task *ssl_sock_io_cb(struct task *t, void *context, unsigned int state)
|
|||
void *xprt_ctx_hs = NULL;
|
||||
|
||||
ret = ops->init(conn, &xprt_ctx_hs);
|
||||
BUG_ON(ret);
|
||||
/* Frontend conn must be freed in case of XPRT init failure. */
|
||||
if (ret) {
|
||||
if (!conn_is_back(conn)) {
|
||||
conn->flags |= CO_FL_ERROR; /* Ensure conn will be freed on next call. */
|
||||
ret = conn_complete_session(conn);
|
||||
BUG_ON(ret >= 0); /* conn_complete_session() expected to fail on CO_FL_ERROR */
|
||||
t = NULL;
|
||||
}
|
||||
goto leave;
|
||||
}
|
||||
|
||||
ret = ops->add_xprt(conn, xprt_ctx_hs,
|
||||
conn->xprt_ctx, conn->xprt, NULL, NULL);
|
||||
BUG_ON(ret);
|
||||
BUG_ON(ret); /* xprt_qmux add_xprt always succeeds */
|
||||
|
||||
conn->xprt = ops;
|
||||
conn->xprt_ctx = xprt_ctx_hs;
|
||||
|
||||
|
||||
ret = conn->xprt->start(conn, xprt_ctx_hs);
|
||||
BUG_ON(ret);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue