aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-11-27 12:24:44 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-11-27 12:24:44 +0000
commit9683528550836a35cb24c61bf3fd99175bcbd82f (patch)
treeee1b337717e125cddcdaeaf3abb3e58c0794d7b8 /src
parenta6b5957f92fb92d2e7a18b2bec4a91a0e88a28bc (diff)
downloadnginx-9683528550836a35cb24c61bf3fd99175bcbd82f.tar.gz
nginx-9683528550836a35cb24c61bf3fd99175bcbd82f.zip
improve throughput with large limit_rate
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_write_filter_module.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
index e5a26f003..bc62b1817 100644
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -49,6 +49,7 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
off_t size, sent, limit;
ngx_uint_t last, flush;
+ ngx_msec_t delay;
ngx_chain_t *cl, *ln, **ll, *chain;
ngx_connection_t *c;
ngx_http_core_loc_conf_t *clcf;
@@ -245,14 +246,17 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
if (r->limit_rate) {
- sent = c->sent - sent;
- c->write->delayed = 1;
- ngx_add_timer(c->write, (ngx_msec_t) (sent * 1000 / r->limit_rate + 1));
+ delay = (ngx_msec_t) ((c->sent - sent) * 1000 / r->limit_rate + 1);
+
+ if (delay > 0) {
+ c->write->delayed = 1;
+ ngx_add_timer(c->write, delay);
+ }
} else if (c->write->ready
&& clcf->sendfile_max_chunk
&& (size_t) (c->sent - sent)
- >= clcf->sendfile_max_chunk - 2 * ngx_pagesize)
+ >= clcf->sendfile_max_chunk - 2 * ngx_pagesize)
{
c->write->delayed = 1;
ngx_add_timer(c->write, 1);