MINOR: mux-h2: add a new function h2s_alert() to call the data layer

In order to report an error to the data layer, we have different ways
depending on the situation. At a lot of places it's open-coded and not
always correct. Let's create a new function h2s_alert() to handle this
task. It tries to wake on recv() first, then on send(), then using
wake().
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 7a8f71b..11f1a6c 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -247,6 +247,7 @@
 static int h2_frt_transfer_data(struct h2s *h2s);
 static struct task *h2_deferred_shut(struct task *t, void *ctx, unsigned short state);
 static struct h2s *h2c_bck_stream_new(struct h2c *h2c, struct conn_stream *cs, struct session *sess);
+static void h2s_alert(struct h2s *h2s);
 
 /*****************************************************/
 /* functions below are for dynamic buffer management */
@@ -624,6 +625,24 @@
 	}
 }
 
+/* alerts the data layer, trying to wake it up by all means, following
+ * this sequence :
+ *   - if the h2s' data layer is subscribed to recv, then it's woken up for recv
+ *   - if its subscribed to send, then it's woken up for send
+ *   - if it was subscribed to neither, its ->wake() callback is called
+ * It is safe to call this function with a closed stream which doesn't have a
+ * conn_stream anymore.
+ */
+static void __maybe_unused h2s_alert(struct h2s *h2s)
+{
+	if (h2s->recv_wait || h2s->send_wait) {
+		h2s_notify_recv(h2s);
+		h2s_notify_send(h2s);
+	}
+	else if (h2s->cs && h2s->cs->data_cb->wake != NULL)
+		h2s->cs->data_cb->wake(h2s->cs);
+}
+
 /* writes the 24-bit frame size <len> at address <frame> */
 static inline __maybe_unused void h2_set_frame_size(void *frame, uint32_t len)
 {