mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-25 15:51:24 +02:00
BUG/MEDIUM: servers: Only destroy a conn_stream we just allocated.
In connect_server(), if we failed to add the connection to the session, only destroy the conn_stream if we just allocated it, otherwise it may have been allocated outside connect_server(), along with a connection which has its destination address set. Also use si_release_endpoint() instead of cs_destroy(), to make sure the stream_interface doesn't reference it anymore. This should be backported to 1.9.
This commit is contained in:
parent
f67be93ae0
commit
4dc85538ba
@ -1148,6 +1148,7 @@ int connect_server(struct stream *s)
|
||||
int reuse = 0;
|
||||
int reuse_orphan = 0;
|
||||
int init_mux = 0;
|
||||
int alloced_cs = 0;
|
||||
int err;
|
||||
|
||||
|
||||
@ -1325,9 +1326,10 @@ int connect_server(struct stream *s)
|
||||
|
||||
if (avail >= 1) {
|
||||
srv_cs = srv_conn->mux->attach(srv_conn, s->sess);
|
||||
if (srv_cs)
|
||||
if (srv_cs) {
|
||||
alloced_cs = 1;
|
||||
si_attach_cs(&s->si[1], srv_cs);
|
||||
else
|
||||
} else
|
||||
srv_conn = NULL;
|
||||
}
|
||||
else
|
||||
@ -1351,7 +1353,8 @@ int connect_server(struct stream *s)
|
||||
if (!session_add_conn(s->sess, srv_conn, s->target)) {
|
||||
/* If we failed to attach the connection, detach the
|
||||
* conn_stream, possibly destroying the connection */
|
||||
cs_destroy(srv_cs);
|
||||
if (alloced_cs)
|
||||
si_release_endpoint(&s->si[1]);
|
||||
srv_conn->owner = NULL;
|
||||
if (!srv_add_to_idle_list(objt_server(srv_conn->target), srv_conn))
|
||||
/* The server doesn't want it, let's kill the connection right away */
|
||||
|
Loading…
x
Reference in New Issue
Block a user