comparison src/os/unix/ngx_linux_sendfile_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 d620f497c50f
children 23a186e8ca45
comparison
equal deleted inserted replaced
4595:6cd5d4a279d6 4596:089cc5154c1e
87 prev = NULL; 87 prev = NULL;
88 iov = NULL; 88 iov = NULL;
89 89
90 /* create the iovec and coalesce the neighbouring bufs */ 90 /* create the iovec and coalesce the neighbouring bufs */
91 91
92 for (cl = in; 92 for (cl = in; cl && send < limit; cl = cl->next) {
93 cl && header.nelts < IOV_MAX && send < limit; 93
94 cl = cl->next)
95 {
96 if (ngx_buf_special(cl->buf)) { 94 if (ngx_buf_special(cl->buf)) {
97 continue; 95 continue;
98 } 96 }
99 97
100 #if 1 98 #if 1
130 128
131 if (prev == cl->buf->pos) { 129 if (prev == cl->buf->pos) {
132 iov->iov_len += (size_t) size; 130 iov->iov_len += (size_t) size;
133 131
134 } else { 132 } else {
133 if (header.nelts >= IOV_MAX) {
134 break;
135 }
136
135 iov = ngx_array_push(&header); 137 iov = ngx_array_push(&header);
136 if (iov == NULL) { 138 if (iov == NULL) {
137 return NGX_CHAIN_ERROR; 139 return NGX_CHAIN_ERROR;
138 } 140 }
139 141