diff options
author | Igor Sysoev <igor@sysoev.ru> | 2006-04-14 09:34:54 +0000 |
---|---|---|
committer | Jonathan Kolb <jon@b0g.us> | 2006-04-14 09:34:54 +0000 |
commit | 9fdefb1c02ced9046c4a77a0f8017770b362f130 (patch) | |
tree | 9e318a81575bfdeb1d68071ffa4ebf37cf45672a /src/http/ngx_http_write_filter_module.c | |
parent | b3661298bb72848e9c6f73209da256e7ae34ef7b (diff) | |
download | nginx-9fdefb1c02ced9046c4a77a0f8017770b362f130.tar.gz |
Changes with nginx 0.3.38 14 Apr 2006v0.3.38
*) Feature: the ngx_http_dav_module.
*) Change: the ngx_http_perl_module optimizations.
Thanks to Sergey Skvortsov.
*) Feature: the ngx_http_perl_module supports the $r->request_body_file
method.
*) Feature: the "client_body_in_file_only" directive.
*) Workaround: no on disk overflow nginx tries to write access logs
once a second only.
Thanks to Anton Yuzhaninov and Maxim Dounin.
*) Bugfix: now the "limit_rate" directive more precisely limits rate if
rate is more than 100 Kbyte/s.
Thanks to ForJest.
*) Bugfix: now the IMAP/POP3 proxy escapes the "r" and "n" symbols in
login and password to pass authorization server.
Thanks to Maxim Dounin.
Diffstat (limited to 'src/http/ngx_http_write_filter_module.c')
-rw-r--r-- | src/http/ngx_http_write_filter_module.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c index 30f1a72e2..5ae24b030 100644 --- a/src/http/ngx_http_write_filter_module.c +++ b/src/http/ngx_http_write_filter_module.c @@ -47,7 +47,7 @@ ngx_module_t ngx_http_write_filter_module = { ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) { - off_t size, sent; + off_t size, sent, to_send; ngx_uint_t last, flush; ngx_chain_t *cl, *ln, **ll, *chain; ngx_connection_t *c; @@ -209,25 +209,34 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) return NGX_ERROR; } + to_send = r->limit_rate * (ngx_time() - r->start_time + 1) - c->sent; + + if (to_send < 0) { + to_send = 0; + } + sent = c->sent; - chain = c->send_chain(c, r->out, r->limit_rate); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, + "http write filter to send %O", to_send); + + chain = c->send_chain(c, r->out, to_send); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http write filter %p", chain); - if (r->limit_rate) { + if (chain == NGX_CHAIN_ERROR) { + c->error = 1; + return NGX_ERROR; + } + + if (to_send) { sent = c->sent - sent; c->write->delayed = 1; ngx_add_timer(r->connection->write, (ngx_msec_t) (sent * 1000 / r->limit_rate)); } - if (chain == NGX_CHAIN_ERROR) { - c->error = 1; - return NGX_ERROR; - } - for (cl = r->out; cl && cl != chain; /* void */) { ln = cl; cl = cl->next; |