Mercurial > hg > nginx-vendor-0-5
comparison src/http/ngx_http_write_filter_module.c @ 182:13710a1813ad NGINX_0_3_38
nginx 0.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: now 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.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 14 Apr 2006 00:00:00 +0400 |
parents | 36af50a5582d |
children | 71ff1e2b484a |
comparison
equal
deleted
inserted
replaced
181:de8983d10e75 | 182:13710a1813ad |
---|---|
45 | 45 |
46 | 46 |
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; | 50 off_t size, sent, to_send; |
51 ngx_uint_t last, flush; | 51 ngx_uint_t last, flush; |
52 ngx_chain_t *cl, *ln, **ll, *chain; | 52 ngx_chain_t *cl, *ln, **ll, *chain; |
53 ngx_connection_t *c; | 53 ngx_connection_t *c; |
54 ngx_http_core_loc_conf_t *clcf; | 54 ngx_http_core_loc_conf_t *clcf; |
55 | 55 |
207 ngx_debug_point(); | 207 ngx_debug_point(); |
208 | 208 |
209 return NGX_ERROR; | 209 return NGX_ERROR; |
210 } | 210 } |
211 | 211 |
212 to_send = r->limit_rate * (ngx_time() - r->start_time + 1) - c->sent; | |
213 | |
214 if (to_send < 0) { | |
215 to_send = 0; | |
216 } | |
217 | |
212 sent = c->sent; | 218 sent = c->sent; |
213 | 219 |
214 chain = c->send_chain(c, r->out, r->limit_rate); | 220 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
221 "http write filter to send %O", to_send); | |
222 | |
223 chain = c->send_chain(c, r->out, to_send); | |
215 | 224 |
216 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 225 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
217 "http write filter %p", chain); | 226 "http write filter %p", chain); |
218 | 227 |
219 if (r->limit_rate) { | 228 if (chain == NGX_CHAIN_ERROR) { |
229 c->error = 1; | |
230 return NGX_ERROR; | |
231 } | |
232 | |
233 if (to_send) { | |
220 sent = c->sent - sent; | 234 sent = c->sent - sent; |
221 c->write->delayed = 1; | 235 c->write->delayed = 1; |
222 ngx_add_timer(r->connection->write, | 236 ngx_add_timer(r->connection->write, |
223 (ngx_msec_t) (sent * 1000 / r->limit_rate)); | 237 (ngx_msec_t) (sent * 1000 / r->limit_rate)); |
224 } | 238 } |
225 | 239 |
226 if (chain == NGX_CHAIN_ERROR) { | |
227 c->error = 1; | |
228 return NGX_ERROR; | |
229 } | |
230 | |
231 for (cl = r->out; cl && cl != chain; /* void */) { | 240 for (cl = r->out; cl && cl != chain; /* void */) { |
232 ln = cl; | 241 ln = cl; |
233 cl = cl->next; | 242 cl = cl->next; |
234 ngx_free_chain(r->pool, ln); | 243 ngx_free_chain(r->pool, ln); |
235 } | 244 } |