]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: implement qcs_alert()
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 6 Jul 2022 12:54:34 +0000 (14:54 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Jul 2022 14:24:03 +0000 (16:24 +0200)
Implement a simple function to notify a possible subscriber or wake up
the upper layer if a special condition happens on a stream. For the
moment, this is only used to replace identical code in
qc_wake_some_streams().

src/mux_quic.c

index cb3e362ff047a6caf42c9b6af3d8cefdbd72569e..0263c07a6383091f579249cbc41971af06144c86 100644 (file)
@@ -248,6 +248,20 @@ static struct ncbuf *qc_get_ncbuf(struct qcs *qcs, struct ncbuf *ncbuf)
        return ncbuf;
 }
 
+/* Notify an eventual subscriber on <qcs> or else wakup up the stconn layer if
+ * initialized.
+ */
+static void qcs_alert(struct qcs *qcs)
+{
+       if (qcs->subs) {
+               qcs_notify_recv(qcs);
+               qcs_notify_send(qcs);
+       }
+       else if (qcs_sc(qcs) && qcs->sd->sc->app_ops->wake) {
+               qcs->sd->sc->app_ops->wake(qcs->sd->sc);
+       }
+}
+
 int qcs_subscribe(struct qcs *qcs, int event_type, struct wait_event *es)
 {
        struct qcc *qcc = qcs->qcc;
@@ -1746,13 +1760,7 @@ static int qc_wake_some_streams(struct qcc *qcc)
                        if (se_fl_test(qcs->sd, SE_FL_EOS))
                                se_fl_set(qcs->sd, SE_FL_ERROR);
 
-                       if (qcs->subs) {
-                               qcs_notify_recv(qcs);
-                               qcs_notify_send(qcs);
-                       }
-                       else if (qcs->sd->sc->app_ops->wake) {
-                               qcs->sd->sc->app_ops->wake(qcs->sd->sc);
-                       }
+                       qcs_alert(qcs);
                }
        }