]> git.kaiwu.me - nginx.git/commitdiff
Fixed ngx_readv_chain() to honor IOV_MAX (ticket #14).
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 17 Apr 2012 09:13:58 +0000 (09:13 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 17 Apr 2012 09:13:58 +0000 (09:13 +0000)
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.

src/os/unix/ngx_readv_chain.c

index 373c4027cb32b21258889d5910cb25031e15bcb5..7b6badfa8254bfde000e583f687033f4b51a483c 100644 (file)
@@ -71,6 +71,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
             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_chain_t *chain)
             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;