From: Olivier Houchard Date: Sat, 20 Oct 2018 22:32:01 +0000 (+0200) Subject: BUG/MEDIUM: connections: Remove subscription if going in idle mode. X-Git-Tag: v1.9-dev4~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fddc9b7bb59b489f9338fd10dd1eaceffae0cb7;p=thirdparty%2Fhaproxy.git 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 2d4c4c73d2..90c4fddee8 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; } -/* 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 95a8e23173..7860c79c85 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);