Mercurial > hg > nginx
comparison src/core/ngx_buf.c @ 5915:ac3f78219f85
Moved the code for coalescing file buffers to a separate function.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 13 Aug 2014 15:11:45 +0400 |
parents | de68ed551bfb |
children | 40c2f3e06d23 a3e6d660b179 |
comparison
equal
deleted
inserted
replaced
5914:4dd67e5d958e | 5915:ac3f78219f85 |
---|---|
218 *free = cl; | 218 *free = cl; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 off_t | |
224 ngx_chain_coalesce_file(ngx_chain_t **in, off_t limit) | |
225 { | |
226 off_t total, size, aligned, fprev; | |
227 ngx_fd_t fd; | |
228 ngx_chain_t *cl; | |
229 | |
230 total = 0; | |
231 | |
232 cl = *in; | |
233 fd = cl->buf->file->fd; | |
234 | |
235 do { | |
236 size = cl->buf->file_last - cl->buf->file_pos; | |
237 | |
238 if (size > limit - total) { | |
239 size = limit - total; | |
240 | |
241 aligned = (cl->buf->file_pos + size + ngx_pagesize - 1) | |
242 & ~((off_t) ngx_pagesize - 1); | |
243 | |
244 if (aligned <= cl->buf->file_last) { | |
245 size = aligned - cl->buf->file_pos; | |
246 } | |
247 } | |
248 | |
249 total += size; | |
250 fprev = cl->buf->file_pos + size; | |
251 cl = cl->next; | |
252 | |
253 } while (cl | |
254 && cl->buf->in_file | |
255 && total < limit | |
256 && fd == cl->buf->file->fd | |
257 && fprev == cl->buf->file_pos); | |
258 | |
259 *in = cl; | |
260 | |
261 return total; | |
262 } | |
263 | |
264 | |
223 ngx_chain_t * | 265 ngx_chain_t * |
224 ngx_chain_update_sent(ngx_chain_t *in, off_t sent) | 266 ngx_chain_update_sent(ngx_chain_t *in, off_t sent) |
225 { | 267 { |
226 off_t size; | 268 off_t size; |
227 | 269 |