]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connections: Remove subscription if going in idle mode.
authorOlivier Houchard <cognet@ci0.org>
Sat, 20 Oct 2018 22:32:01 +0000 (00:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Oct 2018 03:55:20 +0000 (05:55 +0200)
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
include/proto/stream_interface.h

index 2d4c4c73d21f267ca2537cc953af9a402950a720..90c4fddee84b4ee57b5dbc498d6cdf965ab6a9d3 100644 (file)
@@ -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);
 }
 
index 95a8e2317359258349bdf802ab15ed62f241c428..7860c79c857272c7cc6aee10c0cd1a7b96f96834 100644 (file)
@@ -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);