diff src/os/unix/ngx_solaris_sendfilev_chain.c @ 4596:089cc5154c1e

IOV_MAX handling microoptimization. We now stop on IOV_MAX iovec entries only if we are going to add new one, i.e. next buffer can't be coalesced into last iovec. This also fixes incorrect checks for trailer creation on FreeBSD and Mac OS X, header.nelts was checked instead of trailer.nelts.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 17 Apr 2012 09:13:15 +0000
parents 6cd5d4a279d6
children 4c36e15651f7
line wrap: on
line diff
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -94,8 +94,8 @@ ngx_solaris_sendfilev_chain(ngx_connecti
 
         /* create the sendfilevec and coalesce the neighbouring bufs */
 
-        for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next)
-        {
+        for (cl = in; cl && send < limit; cl = cl->next) {
+
             if (ngx_buf_special(cl->buf)) {
                 continue;
             }
@@ -113,6 +113,10 @@ ngx_solaris_sendfilev_chain(ngx_connecti
                     sfv->sfv_len += (size_t) size;
 
                 } else {
+                    if (vec.nelts >= IOV_MAX) {
+                        break;
+                    }
+
                     sfv = ngx_array_push(&vec);
                     if (sfv == NULL) {
                         return NGX_CHAIN_ERROR;
@@ -147,6 +151,10 @@ ngx_solaris_sendfilev_chain(ngx_connecti
                     sfv->sfv_len += (size_t) size;
 
                 } else {
+                    if (vec.nelts >= IOV_MAX) {
+                        break;
+                    }
+
                     sfv = ngx_array_push(&vec);
                     if (sfv == NULL) {
                         return NGX_CHAIN_ERROR;