diff src/event/quic/ngx_event_quic_frames.c @ 8967:3789f4a56d65 quic

QUIC: return written size from ngx_quic_write_chain(). This allows to escape calculating it before calling the function.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 13 Jan 2022 11:34:42 +0300
parents 5acd0d89d8c2
children 065c73221b7b
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic_frames.c
+++ b/src/event/quic/ngx_event_quic_frames.c
@@ -478,13 +478,17 @@ ngx_quic_copy_buf(ngx_connection_t *c, u
 
 ngx_chain_t *
 ngx_quic_write_chain(ngx_connection_t *c, ngx_chain_t **chain, ngx_chain_t *in,
-    off_t limit, off_t offset)
+    off_t limit, off_t offset, size_t *size)
 {
     off_t         n;
     u_char       *p;
     ngx_buf_t    *b;
     ngx_chain_t  *cl, *sl;
 
+    if (size) {
+        *size = 0;
+    }
+
     while (in && limit) {
         cl = *chain;
 
@@ -549,6 +553,10 @@ ngx_quic_write_chain(ngx_connection_t *c
             in->buf->pos += n;
             offset += n;
             limit -= n;
+
+            if (size) {
+                *size += n;
+            }
         }
 
         if (b->sync && p == b->last) {