diff src/os/unix/ngx_solaris_sendfilev_chain.c @ 262:8c5bdde0d9f0

nginx-0.0.2-2004-02-18-18:45:21 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 18 Feb 2004 15:45:21 +0000
parents 70e1c7d2b83d
children d4e65d74db9f
line wrap: on
line diff
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -16,7 +16,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain
     sendfilevec_t  *sfv;
     ngx_array_t     vec;
     ngx_event_t    *wev;
-    ngx_chain_t    *cl;
+    ngx_chain_t    *cl, *tail;
 
     wev = c->write;
 
@@ -37,7 +37,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain
 
         /* create the sendfilevec and coalesce the neighbouring hunks */
 
-        for (cl = in; cl; cl = cl->next) {
+        for (cl = in; cl && vec.nelts < IOV_MAX; cl = cl->next) {
             if (ngx_hunk_special(cl->hunk)) {
                 continue;
             }
@@ -77,6 +77,13 @@ ngx_chain_t *ngx_solaris_sendfilev_chain
             }
         }
 
+        /*
+         * the tail is the rest of the chain that exceeded a single
+         * sendfilev() capability, IOV_MAX in Solaris is only 16
+         */
+
+        tail = cl;
+
         n = sendfilev(c->fd, vec.elts, vec.nelts, &sent);
 
         if (n == -1) {
@@ -142,7 +149,9 @@ ngx_chain_t *ngx_solaris_sendfilev_chain
 
         in = cl;
 
-    } while (eintr);
+        /* "tail == in" means that a single sendfilev() is complete */
+
+    } while ((tail && tail == in) || eintr);
 
     if (in) {
         wev->ready = 0;