BUG/MEDIUM: connections: Remove subscription if going in idle mode.
Make sure we don't have any subscription when the connection is going in
idle mode, otherwise there's a race condition when the connection is
reused, if there are still old subscriptions, new ones won't be done.
No backport is needed.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 2d4c4c7..90c4fdd 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -701,13 +701,23 @@
return cs;
}
-/* Releases a connection previously allocated by conn_new() */
-static inline void conn_free(struct connection *conn)
+static inline void conn_force_unsubscribe(struct connection *conn)
{
- if (conn->recv_wait)
+ if (conn->recv_wait) {
conn->recv_wait->wait_reason &= ~SUB_CAN_RECV;
- if (conn->send_wait)
+ conn->recv_wait = NULL;
+ }
+ if (conn->send_wait) {
conn->send_wait->wait_reason &= ~SUB_CAN_SEND;
+ conn->send_wait = NULL;
+ }
+
+}
+
+/* Releases a connection previously allocated by conn_new() */
+static inline void conn_free(struct connection *conn)
+{
+ conn_force_unsubscribe(conn);
pool_free(pool_head_connection, conn);
}
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 95a8e23..7860c79 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -194,6 +194,7 @@
struct conn_stream *cs = __objt_cs(si->end);
struct connection *conn = cs->conn;
+ conn_force_unsubscribe(conn);
if (pool)
LIST_ADD(pool, &conn->list);