]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC REACTOR: Move can-poll flags into reactor
authorHugo Landau <hlandau@openssl.org>
Wed, 9 Aug 2023 16:46:32 +0000 (17:46 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 1 Sep 2023 09:45:34 +0000 (10:45 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21715)

include/internal/quic_reactor.h
ssl/quic/quic_reactor.c

index 6a8ebbe29dbf823f88a2c76bb78121a0f1f344a6..2ca32f17ac4392ef10afd218dc0f3df3ea0d9279 100644 (file)
@@ -94,6 +94,13 @@ typedef struct quic_reactor_st {
      */
     unsigned int net_read_desired   : 1;
     unsigned int net_write_desired  : 1;
+
+    /*
+     * Are the read and write poll descriptors we are currently configured with
+     * things we can actually poll?
+     */
+    unsigned int can_poll_r : 1;
+    unsigned int can_poll_w : 1;
 } QUIC_REACTOR;
 
 void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
@@ -108,12 +115,16 @@ void ossl_quic_reactor_set_poll_r(QUIC_REACTOR *rtor,
 void ossl_quic_reactor_set_poll_w(QUIC_REACTOR *rtor,
                                   const BIO_POLL_DESCRIPTOR *w);
 
-const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_r(QUIC_REACTOR *rtor);
+const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_r(const QUIC_REACTOR *rtor);
+const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_w(const QUIC_REACTOR *rtor);
 
-const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_w(QUIC_REACTOR *rtor);
+int ossl_quic_reactor_can_poll_r(const QUIC_REACTOR *rtor);
+int ossl_quic_reactor_can_poll_w(const QUIC_REACTOR *rtor);
 
-int ossl_quic_reactor_net_read_desired(QUIC_REACTOR *rtor);
+int ossl_quic_reactor_can_support_poll_descriptor(const QUIC_REACTOR *rtor,
+                                                  const BIO_POLL_DESCRIPTOR *d);
 
+int ossl_quic_reactor_net_read_desired(QUIC_REACTOR *rtor);
 int ossl_quic_reactor_net_write_desired(QUIC_REACTOR *rtor);
 
 OSSL_TIME ossl_quic_reactor_get_tick_deadline(QUIC_REACTOR *rtor);
index f89337b38e6f7ace9ffb9c7f6c3727b399fc29a0..9aea218d27d012c64e3783b4acacedbc745153c2 100644 (file)
@@ -24,6 +24,8 @@ void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
     rtor->poll_w.type       = BIO_POLL_DESCRIPTOR_TYPE_NONE;
     rtor->net_read_desired  = 0;
     rtor->net_write_desired = 0;
+    rtor->can_poll_r        = 0;
+    rtor->can_poll_w        = 0;
     rtor->tick_deadline     = initial_tick_deadline;
 
     rtor->tick_cb           = tick_cb;
@@ -32,24 +34,52 @@ void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
 
 void ossl_quic_reactor_set_poll_r(QUIC_REACTOR *rtor, const BIO_POLL_DESCRIPTOR *r)
 {
-    rtor->poll_r = *r;
+    if (r == NULL)
+        rtor->poll_r.type = BIO_POLL_DESCRIPTOR_TYPE_NONE;
+    else
+        rtor->poll_r = *r;
+
+    rtor->can_poll_r
+        = ossl_quic_reactor_can_support_poll_descriptor(rtor, &rtor->poll_r);
 }
 
 void ossl_quic_reactor_set_poll_w(QUIC_REACTOR *rtor, const BIO_POLL_DESCRIPTOR *w)
 {
-    rtor->poll_w = *w;
+    if (w == NULL)
+        rtor->poll_w.type = BIO_POLL_DESCRIPTOR_TYPE_NONE;
+    else
+        rtor->poll_w = *w;
+
+    rtor->can_poll_w
+        = ossl_quic_reactor_can_support_poll_descriptor(rtor, &rtor->poll_w);
 }
 
-const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_r(QUIC_REACTOR *rtor)
+const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_r(const QUIC_REACTOR *rtor)
 {
     return &rtor->poll_r;
 }
 
-const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_w(QUIC_REACTOR *rtor)
+const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_w(const QUIC_REACTOR *rtor)
 {
     return &rtor->poll_w;
 }
 
+int ossl_quic_reactor_can_support_poll_descriptor(const QUIC_REACTOR *rtor,
+                                                  const BIO_POLL_DESCRIPTOR *d)
+{
+    return d->type == BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD;
+}
+
+int ossl_quic_reactor_can_poll_r(const QUIC_REACTOR *rtor)
+{
+    return rtor->can_poll_r;
+}
+
+int ossl_quic_reactor_can_poll_w(const QUIC_REACTOR *rtor)
+{
+    return rtor->can_poll_w;
+}
+
 int ossl_quic_reactor_net_read_desired(QUIC_REACTOR *rtor)
 {
     return rtor->net_read_desired;