diff --git a/include/haproxy/session.h b/include/haproxy/session.h index 8174a2ae7..fa21dda6c 100644 --- a/include/haproxy/session.h +++ b/include/haproxy/session.h @@ -78,9 +78,20 @@ static inline void session_unown_conn(struct session *sess, struct connection *c { struct sess_srv_list *srv_list = NULL; + /* WT: this currently is a workaround for an inconsistency between + * the link status of the connection in the session list and the + * connection's owner. This should be removed as soon as all this + * is addressed. Right now it's possible to enter here with a non-null + * conn->owner that points to a dead session, but in this case the + * element is not linked. + */ + if (!LIST_ADDED(&conn->session_list)) + return; + if (conn->flags & CO_FL_SESS_IDLE) sess->idle_conns--; LIST_DEL_INIT(&conn->session_list); + conn->owner = NULL; list_for_each_entry(srv_list, &sess->srv_list, srv_list) { if (srv_list->target == conn->target) { if (LIST_ISEMPTY(&srv_list->conn_list)) { diff --git a/src/session.c b/src/session.c index b065ff3d2..710b6b6f6 100644 --- a/src/session.c +++ b/src/session.c @@ -99,6 +99,7 @@ void session_free(struct session *sess) void conn_session_free(struct connection *conn) { session_free(conn->owner); + conn->owner = NULL; } /* count a new session to keep frontend, listener and track stats up to date */