[nginx] Use only preallocated memory in ngx_readv_chain() (ticket #1408).

Ruslan Ermilov ru at nginx.com
Mon Jul 5 16:34:26 UTC 2021


details:   https://hg.nginx.org/nginx/rev/7f5e3595caff
branches:  
changeset: 7886:7f5e3595caff
user:      Ruslan Ermilov <ru at nginx.com>
date:      Mon Jul 05 13:09:23 2021 +0300
description:
Use only preallocated memory in ngx_readv_chain() (ticket #1408).

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.

diffstat:

 src/os/unix/ngx_readv_chain.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r e0fdd75871e4 -r 7f5e3595caff src/os/unix/ngx_readv_chain.c
--- a/src/os/unix/ngx_readv_chain.c	Mon Jun 28 18:01:24 2021 +0300
+++ b/src/os/unix/ngx_readv_chain.c	Mon Jul 05 13:09:23 2021 +0300
@@ -96,7 +96,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx
             iov->iov_len += n;
 
         } else {
-            if (vec.nelts >= IOV_MAX) {
+            if (vec.nelts == vec.nalloc) {
                 break;
             }
 


More information about the nginx-devel mailing list