changeset 8332:6ad871b63422 quic

Cleaned up magic numbers in ngx_quic_output_frames().
author Vladimir Homutov <vl@nginx.com>
date Mon, 13 Apr 2020 14:57:58 +0300
parents bda817d16cc2
children 167d32476737
files src/event/ngx_event_quic.c
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -161,7 +161,7 @@ static void ngx_quic_queue_frame(ngx_qui
 
 static ngx_int_t ngx_quic_output(ngx_connection_t *c);
 static ngx_int_t ngx_quic_output_frames(ngx_connection_t *c,
-    ngx_quic_send_ctx_t *ctx, ngx_uint_t nsi);
+    ngx_quic_send_ctx_t *ctx);
 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames);
 static ngx_int_t ngx_quic_send_frames(ngx_connection_t *c, ngx_queue_t *frames);
 
@@ -1693,7 +1693,7 @@ ngx_quic_output(ngx_connection_t *c)
     qc = c->quic;
 
     for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
-        if (ngx_quic_output_frames(c, &qc->send_ctx[i], i) != NGX_OK) {
+        if (ngx_quic_output_frames(c, &qc->send_ctx[i]) != NGX_OK) {
             return NGX_ERROR;
         }
     }
@@ -1712,8 +1712,7 @@ ngx_quic_output(ngx_connection_t *c)
 
 
 static ngx_int_t
-ngx_quic_output_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
-    ngx_uint_t nsi)
+ngx_quic_output_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
 {
     size_t                  len, hlen, n;
     ngx_int_t               rc;
@@ -1727,13 +1726,14 @@ ngx_quic_output_frames(ngx_connection_t 
         return NGX_OK;
     }
 
-    hlen = (nsi == 2) ? NGX_QUIC_MAX_SHORT_HEADER
-                      : NGX_QUIC_MAX_LONG_HEADER;
-
+    q = ngx_queue_head(&ctx->frames);
+    f = ngx_queue_data(q, ngx_quic_frame_t, queue);
+
+    /* all frames in same send_ctx share same level */
+    hlen = (f->level == ssl_encryption_application) ? NGX_QUIC_MAX_SHORT_HEADER
+                                                    : NGX_QUIC_MAX_LONG_HEADER;
     hlen += EVP_GCM_TLS_TAG_LEN;
 
-    q = ngx_queue_head(&ctx->frames);
-
     do {
         len = 0;
         ngx_queue_init(&range);