]> git.kaiwu.me - nginx.git/commitdiff
Use only preallocated memory in ngx_readv_chain() (ticket #1408).
authorRuslan Ermilov <ru@nginx.com>
Mon, 5 Jul 2021 10:09:23 +0000 (13:09 +0300)
committerRuslan Ermilov <ru@nginx.com>
Mon, 5 Jul 2021 10:09:23 +0000 (13:09 +0300)
In d1bde5c3c5d2, the number of preallocated iovec's for ngx_readv_chain()
was increased.  Still, in some setups, the function might allocate memory
for iovec's from a connection pool, which is only freed when closing the
connection.

The ngx_readv_chain() function was modified to use only preallocated
memory, similarly to the ngx_writev_chain() change in 8e903522c17a.

src/os/unix/ngx_readv_chain.c

index a3577ce19212dc071d5abdf4f4977640bf77af2f..b1ae4b51d2e40a342ca6223fb1d004838f515530 100644 (file)
@@ -96,7 +96,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
             iov->iov_len += n;
 
         } else {
-            if (vec.nelts >= IOV_MAX) {
+            if (vec.nelts == vec.nalloc) {
                 break;
             }