changeset 4597:4be36d5e78ae

Fixed ngx_readv_chain() to honor IOV_MAX (ticket #14). Not using full chain passed is ok as consumers are expected to check event's ready flag to determine if another call is needed, not the returned size.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 17 Apr 2012 09:13:58 +0000
parents 089cc5154c1e
children 01a21ee8f8bb
files src/os/unix/ngx_readv_chain.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -71,6 +71,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx
             iov->iov_len += chain->buf->end - chain->buf->last;
 
         } else {
+            if (vec.nelts >= IOV_MAX) {
+                break;
+            }
+
             iov = ngx_array_push(&vec);
             if (iov == NULL) {
                 return NGX_ERROR;
@@ -195,6 +199,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx
             iov->iov_len += chain->buf->end - chain->buf->last;
 
         } else {
+            if (vec.nelts >= IOV_MAX) {
+                break;
+            }
+
             iov = ngx_array_push(&vec);
             if (iov == NULL) {
                 return NGX_ERROR;