]> git.kaiwu.me - nginx.git/commitdiff
QUIC: speeding up handshake completion.
authorSergey Kandaurov <pluknet@nginx.com>
Thu, 1 Oct 2020 11:10:22 +0000 (12:10 +0100)
committerSergey Kandaurov <pluknet@nginx.com>
Thu, 1 Oct 2020 11:10:22 +0000 (12:10 +0100)
As per quic-recovery draft, section-6.2.3: resend CRYPTO frames
when receiving an Initial packet containing duplicate CRYPTO data.

src/event/ngx_event_quic.c

index 82bb8902d929ea62deaf5bfaa46c32ef6e2d9c97..f223f5d7fd2a95155f9f1033ec1c5973d33f99ae 100644 (file)
@@ -2661,7 +2661,7 @@ ngx_quic_handle_ordered_frame(ngx_connection_t *c, ngx_quic_frames_stream_t *fs,
             == NGX_DONE)
         {
             /* old/duplicate data range */
-            return NGX_OK;
+            return handler == ngx_quic_crypto_input ? NGX_DECLINED : NGX_OK;
         }
 
         /* intersecting data range, frame modified */
@@ -2844,6 +2844,7 @@ ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
     ngx_quic_frame_t *frame)
 {
     uint64_t                   last;
+    ngx_int_t                  rc;
     ngx_quic_connection_t     *qc;
     ngx_quic_crypto_frame_t   *f;
     ngx_quic_frames_stream_t  *fs;
@@ -2860,8 +2861,19 @@ ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
         return NGX_ERROR;
     }
 
-    return ngx_quic_handle_ordered_frame(c, fs, frame, ngx_quic_crypto_input,
-                                         NULL);
+    rc = ngx_quic_handle_ordered_frame(c, fs, frame, ngx_quic_crypto_input,
+                                       NULL);
+    if (rc != NGX_DECLINED) {
+        return rc;
+    }
+
+    /* speeding up handshake completion */
+
+    if (pkt->level == ssl_encryption_initial) {
+        ngx_quic_resend_frames(c, ngx_quic_get_send_ctx(qc, pkt->level));
+    }
+
+    return NGX_OK;
 }