]> git.kaiwu.me - nginx.git/commitdiff
QUIC: improved size calculation in ngx_quic_write_chain().
authorRoman Arutyunyan <arut@nginx.com>
Thu, 3 Feb 2022 18:29:05 +0000 (21:29 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 3 Feb 2022 18:29:05 +0000 (21:29 +0300)
Previously, size was calculated based on the number of input bytes processed
by the function.  Now only the copied bytes are considered.  This prevents
overlapping buffers from contributing twice to the overall written size.

src/event/quic/ngx_event_quic_frames.c

index 951b6e8a22ff156529b3839224434eeaa1aab4d5..4fa6c56c5aac5264ab8e7bfcf5d66757ee519343 100644 (file)
@@ -554,16 +554,16 @@ ngx_quic_write_chain(ngx_connection_t *c, ngx_chain_t **chain, ngx_chain_t *in,
 
             if (b->sync) {
                 ngx_memcpy(p, in->buf->pos, n);
+
+                if (size) {
+                    *size += n;
+                }
             }
 
             p += n;
             in->buf->pos += n;
             offset += n;
             limit -= n;
-
-            if (size) {
-                *size += n;
-            }
         }
 
         if (b->sync && p == b->last) {