]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
read_from_ssl_ids() before wait_for_activity if something was received
authorJean-Frederic Clere <jfclere@gmail.com>
Wed, 30 Oct 2024 17:06:07 +0000 (18:06 +0100)
committerNeil Horman <nhorman@openssl.org>
Sat, 11 Jan 2025 21:02:29 +0000 (16:02 -0500)
before and the first time we are in the loop.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

demos/http3/ossl-nghttp3-demo-server.c

index 52da9c2e77bf060bd33ddf2d29a8bd5dd437925b..079df569a166f603a5415ef4757b0034610b86ff 100644 (file)
@@ -409,10 +409,10 @@ static int read_from_ssl_ids(nghttp3_conn *h3conn, struct h3ssl *h3ssl)
 
     /* We have something */
     item = items;
-    /* SSL_accept_stream if anyway */
+    /* SSL_accept_stream if SSL_POLL_EVENT_ISB or SSL_POLL_EVENT_ISU */
     if ((item->revents & SSL_POLL_EVENT_ISB) ||
         (item->revents & SSL_POLL_EVENT_ISU)) {
-        SSL *stream = SSL_accept_stream(ssl_ids[0].s, 0);
+        SSL *stream = SSL_accept_stream(item->desc.value.ssl, 0);
         uint64_t id;
         int r;
 
@@ -501,7 +501,7 @@ static int read_from_ssl_ids(nghttp3_conn *h3conn, struct h3ssl *h3ssl)
         /* we missed something we need to figure out */
         printf("Missed revent %llu (%d) on %llu\n",
                (unsigned long long)item->revents, SSL_POLL_EVENT_W,
-               (unsigned long long)ssl_ids[i].id);
+               (unsigned long long)SSL_get_stream_id(item->desc.value.ssl));
     }
     if (result_count == 1 && !processed_event) {
         printf("read_from_ssl_ids 1 event only!\n");
@@ -873,6 +873,7 @@ static int run_quic_server(SSL_CTX *ctx, int fd)
         int ret;
         int numtimeout;
         char slength[11];
+        int hasnothing;
 
         if (!hassomething) {
             printf("waiting on socket\n");
@@ -1084,14 +1085,16 @@ restart:
 
         /* wait until closed */
 wait_close:
+        hasnothing = 0;
         for (;;) {
-            int hasnothing;
 
-            ret = wait_for_activity(h3ssl.ssl_ids[0].s);
-            if (ret == -1)
-                goto err;
-            if (ret == 0) {
-                printf("hasnothing timeout\n");
+            if (hasnothing) {
+                ret = wait_for_activity(h3ssl.ssl_ids[0].s);
+                if (ret == -1)
+                    goto err;
+                if (ret == 0) {
+                    printf("hasnothing timeout\n");
+                }
             }
             hasnothing = read_from_ssl_ids(h3conn, &h3ssl);
             if (hasnothing == -1) {