set delay only when almost whole sendfile_max_chunk was transferred
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c index 944593a..b179664 100644 --- a/src/http/ngx_http_write_filter_module.c +++ b/src/http/ngx_http_write_filter_module.c
@@ -249,7 +249,10 @@ c->write->delayed = 1; ngx_add_timer(c->write, (ngx_msec_t) (sent * 1000 / r->limit_rate + 1)); - } else if (c->write->ready && clcf->sendfile_max_chunk) { + } else if (c->write->ready + && clcf->sendfile_max_chunk + && c->sent - sent >= clcf->sendfile_max_chunk - 2 * ngx_pagesize) + { c->write->delayed = 1; ngx_add_timer(c->write, 1); }