comparison src/os/unix/ngx_darwin_sendfile_chain.c @ 672:f41d4b305d22 NGINX_1_2_0

nginx 1.2.0 *) Bugfix: a segmentation fault might occur in a worker process if the "try_files" directive was used; the bug had appeared in 1.1.19. *) Bugfix: response might be truncated if there were more than IOV_MAX buffers used. *) Bugfix: in the "crop" parameter of the "image_filter" directive. Thanks to Maxim Bublis.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Apr 2012 00:00:00 +0400
parents f5b859b2f097
children
comparison
equal deleted inserted replaced
671:47cb3497fbab 672:f41d4b305d22
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