MINOR: mux-h2: report a trace event when failing to create a new stream

There are two reasons we can reject the creation of an h2 stream on the
frontend:
  - its creation would violate the MAX_CONCURRENT_STREAMS setting
  - there's no more memory available

And on the backend it's almost the same except that the setting might
have be negotiated after trying to set up the stream.

Let's add traces for such a sitaution so that it's possible to know why
the stream was rejected (currently we only know it was rejected).

It could be nice to backport this to the most recent versions.

(cherry picked from commit e872f75fc453baba9cb07b0383096ab6fcb8fb76)
[wt: adjust ctx: dropped the irrelevant to 2.5 cs_attach_mux() part]
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit aa4a1d39849d9e5b4524202813a6e1154b0c60dd)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/mux_h2.c b/src/mux_h2.c
index a726f51..5916ee8 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1565,12 +1565,14 @@
 
 	TRACE_ENTER(H2_EV_H2S_NEW, h2c->conn);
 
-	if (h2c->nb_streams >= h2_settings_max_concurrent_streams)
+	if (h2c->nb_streams >= h2_settings_max_concurrent_streams) {
+		TRACE_ERROR("HEADERS frame causing MAX_CONCURRENT_STREAMS to be exceeded", H2_EV_H2S_NEW|H2_EV_RX_FRAME|H2_EV_RX_HDR, h2c->conn);
 		goto out;
+	}
 
 	h2s = h2s_new(h2c, id);
 	if (!h2s)
-		goto out;
+		goto out_alloc;
 
 	cs = cs_new(h2c->conn, h2c->conn->target);
 	if (!cs)
@@ -1620,6 +1622,8 @@
 	h2s->cs = NULL;
  out_close:
 	h2s_destroy(h2s);
+ out_alloc:
+	TRACE_ERROR("Failed to allocate a new stream", H2_EV_H2S_NEW|H2_EV_RX_FRAME|H2_EV_RX_HDR, h2c->conn);
  out:
 	sess_log(sess);
 	TRACE_LEAVE(H2_EV_H2S_NEW|H2_EV_H2S_ERR|H2_EV_H2S_END, h2c->conn);
@@ -1636,16 +1640,22 @@
 
 	TRACE_ENTER(H2_EV_H2S_NEW, h2c->conn);
 
-	if (h2c->nb_streams >= h2c->streams_limit)
+	if (h2c->nb_streams >= h2c->streams_limit) {
+		TRACE_ERROR("Aborting stream since negotiated limit is too low", H2_EV_H2S_NEW, h2c->conn);
 		goto out;
+	}
 
-	if (h2_streams_left(h2c) < 1)
+	if (h2_streams_left(h2c) < 1) {
+		TRACE_ERROR("Aborting stream since no more streams left", H2_EV_H2S_NEW, h2c->conn);
 		goto out;
+	}
 
 	/* Defer choosing the ID until we send the first message to create the stream */
 	h2s = h2s_new(h2c, 0);
-	if (!h2s)
+	if (!h2s) {
+		TRACE_ERROR("Failed to allocate a new stream", H2_EV_H2S_NEW, h2c->conn);
 		goto out;
+	}
 
 	h2s->cs = cs;
 	h2s->sess = sess;