Mercurial > hg > nginx
comparison src/http/ngx_http_write_filter_module.c @ 7947:51a260276425
Simplified sendfile_max_chunk handling.
Previously, it was checked that sendfile_max_chunk was enabled and
almost whole sendfile_max_chunk was sent (see e67ef50c3176), to avoid
delaying connections where sendfile_max_chunk wasn't reached (for example,
when sending responses smaller than sendfile_max_chunk). Now we instead
check if there are unsent data, and the connection is still ready for writing.
Additionally we also check c->write->delayed to ignore connections already
delayed by limit_rate.
This approach is believed to be more robust, and correctly handles
not only sendfile_max_chunk, but also internal limits of c->send_chain(),
such as sendfile() maximum supported length (ticket #1870).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 29 Oct 2021 20:21:48 +0300 |
parents | 61e9c078ee3d |
children | 32b0ba4855a6 61d0fa67b55e |
comparison
equal
deleted
inserted
replaced
7946:61e9c078ee3d | 7947:51a260276425 |
---|---|
319 } | 319 } |
320 | 320 |
321 delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); | 321 delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate); |
322 | 322 |
323 if (delay > 0) { | 323 if (delay > 0) { |
324 limit = 0; | |
325 c->write->delayed = 1; | 324 c->write->delayed = 1; |
326 ngx_add_timer(c->write, delay); | 325 ngx_add_timer(c->write, delay); |
327 } | 326 } |
328 } | 327 } |
329 | 328 |
330 if (limit | 329 if (chain && c->write->ready && !c->write->delayed) { |
331 && c->write->ready | |
332 && c->sent - sent >= limit - (off_t) (2 * ngx_pagesize)) | |
333 { | |
334 ngx_post_event(c->write, &ngx_posted_next_events); | 330 ngx_post_event(c->write, &ngx_posted_next_events); |
335 } | 331 } |
336 | 332 |
337 for (cl = r->out; cl && cl != chain; /* void */) { | 333 for (cl = r->out; cl && cl != chain; /* void */) { |
338 ln = cl; | 334 ln = cl; |