BUG/MAJOR: threads/queue: avoid recursive locking in pendconn_get_next_strm()
pendconn_get_next_strm() is called from process_srv_queue() under the
server lock, and calls stream_add_srv_conn() with this lock held, while
the latter tries to take it again. This results in a deadlock when
a server's maxconn is reached and haproxy is built with thread support.
diff --git a/include/proto/stream.h b/include/proto/stream.h
index 938c58d..f3fb095 100644
--- a/include/proto/stream.h
+++ b/include/proto/stream.h
@@ -296,11 +296,16 @@
}
}
-static void inline stream_add_srv_conn(struct stream *sess, struct server *srv)
+static void inline __stream_add_srv_conn(struct stream *sess, struct server *srv)
{
- HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
sess->srv_conn = srv;
LIST_ADD(&srv->actconns, &sess->by_srv);
+}
+
+static void inline stream_add_srv_conn(struct stream *sess, struct server *srv)
+{
+ HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
+ __stream_add_srv_conn(sess, srv);
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
}