Minor fixes to thread assisted mode
authorHugo Landau <hlandau@openssl.org>
Wed, 22 Feb 2023 16:08:26 +0000 (16:08 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 30 Mar 2023 10:14:09 +0000 (11:14 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20348)

include/internal/quic_tserver.h
ssl/quic/quic_impl.c
ssl/quic/quic_thread_assist.c
ssl/quic/quic_tserver.c

index 4545630a90aacc0a66036053a7e296ecbebe074a..0d0d2014974b2e8f84ff7c4ad57ce16fd3191372 100644 (file)
@@ -60,6 +60,9 @@ int ossl_quic_tserver_set_handshake_mutator(QUIC_TSERVER *srv,
 /* Advances the state machine. */
 int ossl_quic_tserver_tick(QUIC_TSERVER *srv);
 
+/* Returns 1 if we have a (non-terminated) client. */
+int ossl_quic_tserver_is_connected(QUIC_TSERVER *srv);
+
 /*
  * Returns 1 if we have finished the TLS handshake
  */
@@ -72,6 +75,7 @@ QUIC_TERMINATE_CAUSE ossl_quic_tserver_get_terminate_cause(const QUIC_TSERVER *s
 
 /* Returns 1 if the server is in a terminated state */
 int ossl_quic_tserver_is_terminated(const QUIC_TSERVER *srv);
+
 /*
  * Attempts to read from stream 0. Writes the number of bytes read to
  * *bytes_read and returns 1 on success. If no bytes are available, 0 is written
index 483b694c7d222e2271244049909abe56c004b985..2c7c247260cf4e89672b5ab7bad8fec83a6e3aed 100644 (file)
@@ -190,8 +190,10 @@ void ossl_quic_free(SSL *s)
 
     quic_lock(qc); /* best effort */
 
-    if (qc->is_thread_assisted && qc->started)
+    if (qc->is_thread_assisted && qc->started) {
         ossl_quic_thread_assist_wait_stopped(&qc->thread_assist);
+        ossl_quic_thread_assist_cleanup(&qc->thread_assist);
+    }
 
     ossl_quic_channel_free(qc->ch);
 
index 9d6c4ecda544a7bad716c5b99e2d0b8d2c6fcbbc..3e2ff1bc6fb8f9d86d722c2c5d7532f9816e7ff4 100644 (file)
@@ -120,11 +120,10 @@ int ossl_quic_thread_assist_cleanup(QUIC_THREAD_ASSIST *qta)
     if (!ossl_assert(qta->joined))
         return 0;
 
-    ossl_crypto_condvar_free(qta->cv);
+    ossl_crypto_condvar_free(&qta->cv);
     ossl_crypto_thread_native_clean(qta->t);
 
     qta->ch     = NULL;
-    qta->cv     = NULL;
     qta->t      = NULL;
     return 1;
 }
index 110e34a83751a18b1c1209d834841a7185413756..27addc9be51c1edbf96f795aaad944c7caed9c88 100644 (file)
@@ -163,6 +163,11 @@ int ossl_quic_tserver_tick(QUIC_TSERVER *srv)
     return 1;
 }
 
+int ossl_quic_tserver_is_connected(QUIC_TSERVER *srv)
+{
+    return ossl_quic_channel_is_active(srv->ch);
+}
+
 /* Returns 1 if the server is in any terminating or terminated state */
 int ossl_quic_tserver_is_term_any(const QUIC_TSERVER *srv)
 {