diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index ab0231642..d216e49a8 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -622,12 +622,14 @@ struct connection { /* second cache line */ struct wait_event *subs; /* Task to wake when awaited events are ready */ union { - struct list idle_list; /* list element for idle connection in server idle list */ - struct mt_list toremove_list; /* list element when idle connection is ready to be purged */ - }; - union { - struct list sess_el; /* used by private backend conns, list elem into session */ - struct list stopping_list; /* used by frontend conns, attach point in mux stopping list */ + /* Backend connections only */ + struct { + struct mt_list toremove_list; /* list element when idle connection is ready to be purged */ + struct list idle_list; /* list element for idle connection in server idle list */ + struct list sess_el; /* used by private connections, list elem into session */ + }; + /* Frontend connections only */ + struct list stopping_list; /* attach point in mux stopping list */ }; union conn_handle handle; /* connection handle at the socket layer */ const struct netns_entry *proxy_netns; diff --git a/src/connection.c b/src/connection.c index 9c5a0fe7a..ea4a0b27b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -467,11 +467,6 @@ void conn_init(struct connection *conn, void *target) conn->target = target; conn->destroy_cb = NULL; conn->proxy_netns = NULL; - MT_LIST_INIT(&conn->toremove_list); - if (conn_is_back(conn)) - LIST_INIT(&conn->sess_el); - else - LIST_INIT(&conn->stopping_list); LIST_INIT(&conn->tlv_list); conn->subs = NULL; conn->src = NULL; @@ -488,6 +483,10 @@ void conn_init(struct connection *conn, void *target) */ static int conn_backend_init(struct connection *conn) { + LIST_INIT(&conn->idle_list); + LIST_INIT(&conn->sess_el); + MT_LIST_INIT(&conn->toremove_list); + if (!sockaddr_alloc(&conn->dst, 0, 0)) return 1; @@ -498,6 +497,12 @@ static int conn_backend_init(struct connection *conn) return 0; } +/* Initialize members used only on frontend connections. */ +static void conn_frontend_init(struct connection *conn) +{ + LIST_INIT(&conn->stopping_list); +} + /* Release connection elements reserved for backend side usage. It also takes * care to detach it if linked to a session or a server instance. * @@ -553,6 +558,9 @@ struct connection *conn_new(void *target) return NULL; } } + else { + conn_frontend_init(conn); + } return conn; } @@ -2967,6 +2975,7 @@ int conn_reverse(struct connection *conn) conn_backend_deinit(conn); + conn_frontend_init(conn); conn->target = &l->obj_type; conn->flags |= CO_FL_ACT_REVERSING; task_wakeup(l->rx.rhttp.task, TASK_WOKEN_RES);