From 1fddc9b7bb59b489f9338fd10dd1eaceffae0cb7 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Sun, 21 Oct 2018 00:32:01 +0200 Subject: [PATCH] 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. --- include/proto/connection.h | 18 ++++++++++++++---- include/proto/stream_interface.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/proto/connection.h b/include/proto/connection.h index 2d4c4c73d..90c4fddee 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -701,13 +701,23 @@ static inline struct conn_stream *cs_new(struct connection *conn) return cs; } +static inline void conn_force_unsubscribe(struct connection *conn) +{ + if (conn->recv_wait) { + conn->recv_wait->wait_reason &= ~SUB_CAN_RECV; + 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) { - if (conn->recv_wait) - conn->recv_wait->wait_reason &= ~SUB_CAN_RECV; - if (conn->send_wait) - conn->send_wait->wait_reason &= ~SUB_CAN_SEND; + 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 95a8e2317..7860c79c8 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -194,6 +194,7 @@ static inline void si_idle_cs(struct stream_interface *si, struct list *pool) struct conn_stream *cs = __objt_cs(si->end); struct connection *conn = cs->conn; + conn_force_unsubscribe(conn); if (pool) LIST_ADD(pool, &conn->list);