Mercurial > hg > nginx
comparison src/os/unix/ngx_darwin_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 | 778ef9c3fd2d |
children | ad137a80919f |
comparison
equal
deleted
inserted
replaced
4595:6cd5d4a279d6 | 4596:089cc5154c1e |
---|---|
101 /* create the header iovec and coalesce the neighbouring bufs */ | 101 /* create the header iovec and coalesce the neighbouring bufs */ |
102 | 102 |
103 prev = NULL; | 103 prev = NULL; |
104 iov = NULL; | 104 iov = NULL; |
105 | 105 |
106 for (cl = in; | 106 for (cl = in; cl && send < limit; cl = cl->next) { |
107 cl && header.nelts < IOV_MAX && send < limit; | 107 |
108 cl = cl->next) | |
109 { | |
110 if (ngx_buf_special(cl->buf)) { | 108 if (ngx_buf_special(cl->buf)) { |
111 continue; | 109 continue; |
112 } | 110 } |
113 | 111 |
114 if (!ngx_buf_in_memory_only(cl->buf)) { | 112 if (!ngx_buf_in_memory_only(cl->buf)) { |
123 | 121 |
124 if (prev == cl->buf->pos) { | 122 if (prev == cl->buf->pos) { |
125 iov->iov_len += (size_t) size; | 123 iov->iov_len += (size_t) size; |
126 | 124 |
127 } else { | 125 } else { |
126 if (header.nelts >= IOV_MAX) { | |
127 break; | |
128 } | |
129 | |
128 iov = ngx_array_push(&header); | 130 iov = ngx_array_push(&header); |
129 if (iov == NULL) { | 131 if (iov == NULL) { |
130 return NGX_CHAIN_ERROR; | 132 return NGX_CHAIN_ERROR; |
131 } | 133 } |
132 | 134 |
176 /* create the trailer iovec and coalesce the neighbouring bufs */ | 178 /* create the trailer iovec and coalesce the neighbouring bufs */ |
177 | 179 |
178 prev = NULL; | 180 prev = NULL; |
179 iov = NULL; | 181 iov = NULL; |
180 | 182 |
181 while (cl && header.nelts < IOV_MAX && send < limit) { | 183 while (cl && send < limit) { |
182 | 184 |
183 if (ngx_buf_special(cl->buf)) { | 185 if (ngx_buf_special(cl->buf)) { |
184 cl = cl->next; | 186 cl = cl->next; |
185 continue; | 187 continue; |
186 } | 188 } |
197 | 199 |
198 if (prev == cl->buf->pos) { | 200 if (prev == cl->buf->pos) { |
199 iov->iov_len += (size_t) size; | 201 iov->iov_len += (size_t) size; |
200 | 202 |
201 } else { | 203 } else { |
204 if (trailer.nelts >= IOV_MAX) { | |
205 break; | |
206 } | |
207 | |
202 iov = ngx_array_push(&trailer); | 208 iov = ngx_array_push(&trailer); |
203 if (iov == NULL) { | 209 if (iov == NULL) { |
204 return NGX_CHAIN_ERROR; | 210 return NGX_CHAIN_ERROR; |
205 } | 211 } |
206 | 212 |