MEDIUM: mux-h2: slightly relax timeout management rules

The H2 timeout rules were arranged to cover complex situations In 2.1
with commit c2ea47fb1 ("BUG/MEDIUM: mux-h2: do not enforce timeout on
long connections").

It turns out that such rules while complex, do not perfectly cover all
use cases. The real intent is to say that as long as there are attached
streams, the connection must not timeout. Then once all these streams
have quit (possibly for timeout reasons) then the mux should take over
the management of timeouts.

We do have this nb_cs field which indicates the number of attached
streams, and it's updated even when leaving orphaned streams. So
checking it alone is sufficient to know whether it's the mux or the
streams that are in charge of the timeouts.

In its current state, this doesn't cause visible effects except that
it makes it impossible to implement more subtle parsing timeouts.

This would need to be backported as far as 2.0 along with the next
commit that will depend on it.

(cherry picked from commit 3439583dd64cc2b0603fd4dac73b7b9506b826bc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a2e750b921e22b877dabc8939f4f39300d311ab7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 11c660e..790349b 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -689,22 +689,14 @@
 }
 
 /* returns true if the connection is allowed to expire, false otherwise. A
- * connection may expire when:
- *   - it has no stream
- *   - it has data in the mux buffer
- *   - it has streams in the blocked list
- *   - it has streams in the fctl list
- *   - it has streams in the send list
- * Otherwise it means some streams are waiting in the data layer and it should
- * not expire.
+ * connection may expire when it has no attached streams. As long as streams
+ * are attached, the application layer is responsible for timeout management,
+ * and each layer will detach when it doesn't want to wait anymore. When the
+ * last one leaves, the connection must take over timeout management.
  */
 static inline int h2c_may_expire(const struct h2c *h2c)
 {
-	return eb_is_empty(&h2c->streams_by_id) ||
-	       br_data(h2c->mbuf) ||
-	       !LIST_ISEMPTY(&h2c->blocked_list) ||
-	       !LIST_ISEMPTY(&h2c->fctl_list) ||
-	       !LIST_ISEMPTY(&h2c->send_list);
+	return !h2c->nb_cs;
 }
 
 static __inline int