MEDIUM: mux: Destroy the stream before trying to add the conn to the idle list.
In the mux_h1 and mux_h2, move the test to see if we should add the
connection in the idle list until after we destroyed the h1s/h2s, that way
later we'll be able to check if the connection has no stream at all, and if
it should be added to the server idling list.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 09c29c2..0a8f874 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -1917,6 +1917,8 @@
{
struct h1s *h1s = cs->ctx;
struct h1c *h1c;
+ int has_keepalive;
+ int is_not_first;
cs->ctx = NULL;
if (!h1s)
@@ -1925,7 +1927,11 @@
h1c = h1s->h1c;
h1s->cs = NULL;
- if (conn_is_back(h1c->conn) && (h1s->flags & H1S_F_WANT_KAL) &&
+ has_keepalive = h1s->flags & H1S_F_WANT_KAL;
+ is_not_first = h1s->flags & H1S_F_NOT_FIRST;
+ h1s_destroy(h1s);
+
+ if (conn_is_back(h1c->conn) && has_keepalive &&
!(h1c->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) {
struct stream_interface *si = cs->data;
struct stream *s = si_strm(si);
@@ -1945,7 +1951,7 @@
if (srv) {
if (h1c->conn->flags & CO_FL_PRIVATE)
LIST_ADD(&srv->priv_conns[tid], &h1c->conn->list);
- else if (h1s->flags & H1S_F_NOT_FIRST)
+ else if (is_not_first)
LIST_ADD(&srv->safe_conns[tid], &h1c->conn->list);
else
LIST_ADD(&srv->idle_conns[tid], &h1c->conn->list);
@@ -1953,8 +1959,6 @@
}
}
- h1s_destroy(h1s);
-
/* We don't want to close right now unless the connection is in error */
if ((h1c->flags & (H1C_F_CS_ERROR|H1C_F_CS_SHUTW)) ||
(h1c->conn->flags & CO_FL_ERROR) || !h1c->conn->owner)