comparison src/os/unix/ngx_files.c @ 642:1b80544421e8 NGINX_1_0_11

nginx 1.0.11 *) Change: now double quotes are encoded in an "echo" SSI-command output. Thanks to Zaur Abasmirzoev. *) Feature: the "image_filter_sharpen" directive. *) Bugfix: a segmentation fault might occur in a worker process if SNI was used; the bug had appeared in 1.0.9. *) Bugfix: SIGWINCH signal did not work after first binary upgrade; the bug had appeared in 1.0.9. *) Bugfix: the "If-Modified-Since", "If-Range", etc. client request header lines might be passed to backend while caching; or not passed without caching if caching was enabled in another part of the configuration. *) Bugfix: in the "scgi_param" directive, if complex parameters were used. *) Bugfix: "add_header" and "expires" directives did not work if a request was proxied and response status code was 206. *) Bugfix: in the "expires @time" directive. *) Bugfix: in the ngx_http_flv_module. Thanks to Piotr Sikora. *) Bugfix: in the ngx_http_mp4_module. *) Bugfix: nginx could not be built on FreeBSD 10. *) Bugfix: nginx could not be built on AIX.
author Igor Sysoev <http://sysoev.ru>
date Thu, 15 Dec 2011 00:00:00 +0400
parents bb20316269e4
children ad25218fd14b
comparison
equal deleted inserted replaced
641:e21c9e01ce08 642:1b80544421e8
151 ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset, 151 ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
152 ngx_pool_t *pool) 152 ngx_pool_t *pool)
153 { 153 {
154 u_char *prev; 154 u_char *prev;
155 size_t size; 155 size_t size;
156 ssize_t n; 156 ssize_t total, n;
157 ngx_array_t vec; 157 ngx_array_t vec;
158 struct iovec *iov, iovs[NGX_IOVS]; 158 struct iovec *iov, iovs[NGX_IOVS];
159 159
160 /* use pwrite() if there is the only buf in a chain */ 160 /* use pwrite() if there is the only buf in a chain */
161 161
162 if (cl->next == NULL) { 162 if (cl->next == NULL) {
163 return ngx_write_file(file, cl->buf->pos, 163 return ngx_write_file(file, cl->buf->pos,
164 (size_t) (cl->buf->last - cl->buf->pos), 164 (size_t) (cl->buf->last - cl->buf->pos),
165 offset); 165 offset);
166 } 166 }
167
168 total = 0;
167 169
168 vec.elts = iovs; 170 vec.elts = iovs;
169 vec.size = sizeof(struct iovec); 171 vec.size = sizeof(struct iovec);
170 vec.nalloc = NGX_IOVS; 172 vec.nalloc = NGX_IOVS;
171 vec.pool = pool; 173 vec.pool = pool;
200 202
201 /* use pwrite() if there is the only iovec buffer */ 203 /* use pwrite() if there is the only iovec buffer */
202 204
203 if (vec.nelts == 1) { 205 if (vec.nelts == 1) {
204 iov = vec.elts; 206 iov = vec.elts;
205 return ngx_write_file(file, (u_char *) iov[0].iov_base, 207
206 iov[0].iov_len, offset); 208 n = ngx_write_file(file, (u_char *) iov[0].iov_base,
209 iov[0].iov_len, offset);
210
211 if (n == NGX_ERROR) {
212 return n;
213 }
214
215 return total + n;
207 } 216 }
208 217
209 if (file->sys_offset != offset) { 218 if (file->sys_offset != offset) {
210 if (lseek(file->fd, offset, SEEK_SET) == -1) { 219 if (lseek(file->fd, offset, SEEK_SET) == -1) {
211 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, 220 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
231 return NGX_ERROR; 240 return NGX_ERROR;
232 } 241 }
233 242
234 file->sys_offset += n; 243 file->sys_offset += n;
235 file->offset += n; 244 file->offset += n;
245 total += n;
236 246
237 } while (cl); 247 } while (cl);
238 248
239 return n; 249 return total;
240 } 250 }
241 251
242 252
243 ngx_int_t 253 ngx_int_t
244 ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s) 254 ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s)
452 462
453 return 0; 463 return 0;
454 } 464 }
455 465
456 466
457 #if (NGX_HAVE_POSIX_FADVISE) 467 #if (NGX_HAVE_POSIX_FADVISE) && !(NGX_HAVE_F_READAHEAD)
458 468
459 ngx_int_t 469 ngx_int_t
460 ngx_read_ahead(ngx_fd_t fd, size_t n) 470 ngx_read_ahead(ngx_fd_t fd, size_t n)
461 { 471 {
462 int err; 472 int err;