comparison src/http/ngx_http_write_filter_module.c @ 348:e10168d6e371 NGINX_0_6_18

nginx 0.6.18 *) Change: now the ngx_http_userid_module adds start time microseconds to the cookie field contains a pid value. *) Change: now the full request line instead of URI only is written to error_log. *) Feature: variables support in the "proxy_pass" directive. *) Feature: the "resolver" and "resolver_timeout" directives. *) Feature: now the directive "add_header last-modified ''" deletes a "Last-Modified" response header line. *) Bugfix: the "limit_rate" directive did not allow to use full throughput, even if limit value was very high.
author Igor Sysoev <http://sysoev.ru>
date Tue, 27 Nov 2007 00:00:00 +0300
parents 5e3b425174f6
children
comparison
equal deleted inserted replaced
347:d53199b68e17 348:e10168d6e371
47 ngx_int_t 47 ngx_int_t
48 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 48 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
49 { 49 {
50 off_t size, sent, limit; 50 off_t size, sent, limit;
51 ngx_uint_t last, flush; 51 ngx_uint_t last, flush;
52 ngx_msec_t delay;
52 ngx_chain_t *cl, *ln, **ll, *chain; 53 ngx_chain_t *cl, *ln, **ll, *chain;
53 ngx_connection_t *c; 54 ngx_connection_t *c;
54 ngx_http_core_loc_conf_t *clcf; 55 ngx_http_core_loc_conf_t *clcf;
55 56
56 c = r->connection; 57 c = r->connection;
243 c->error = 1; 244 c->error = 1;
244 return NGX_ERROR; 245 return NGX_ERROR;
245 } 246 }
246 247
247 if (r->limit_rate) { 248 if (r->limit_rate) {
248 sent = c->sent - sent; 249 delay = (ngx_msec_t) ((c->sent - sent) * 1000 / r->limit_rate + 1);
249 c->write->delayed = 1; 250
250 ngx_add_timer(c->write, (ngx_msec_t) (sent * 1000 / r->limit_rate + 1)); 251 if (delay > 0) {
252 c->write->delayed = 1;
253 ngx_add_timer(c->write, delay);
254 }
251 255
252 } else if (c->write->ready 256 } else if (c->write->ready
253 && clcf->sendfile_max_chunk 257 && clcf->sendfile_max_chunk
254 && (size_t) (c->sent - sent) 258 && (size_t) (c->sent - sent)
255 >= clcf->sendfile_max_chunk - 2 * ngx_pagesize) 259 >= clcf->sendfile_max_chunk - 2 * ngx_pagesize)
256 { 260 {
257 c->write->delayed = 1; 261 c->write->delayed = 1;
258 ngx_add_timer(c->write, 1); 262 ngx_add_timer(c->write, 1);
259 } 263 }
260 264