comparison src/http/ngx_http_write_filter_module.c @ 1194:8ea6caa62c89

style fix: change variable name
author Igor Sysoev <igor@sysoev.ru>
date Sat, 05 May 2007 06:07:11 +0000
parents 6e2216ad2c87
children 493a227edfd5
comparison
equal deleted inserted replaced
1193:ec909315dfb0 1194:8ea6caa62c89
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, to_send; 50 off_t size, sent, limit;
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
208 208
209 return NGX_ERROR; 209 return NGX_ERROR;
210 } 210 }
211 211
212 if (r->limit_rate) { 212 if (r->limit_rate) {
213 to_send = r->limit_rate * (ngx_time() - r->start_sec + 1) - c->sent; 213 limit = r->limit_rate * (ngx_time() - r->start_sec + 1) - c->sent;
214 214
215 if (to_send <= 0) { 215 if (limit <= 0) {
216 c->write->delayed = 1; 216 c->write->delayed = 1;
217 ngx_add_timer(c->write, 217 ngx_add_timer(c->write,
218 (ngx_msec_t) (- to_send * 1000 / r->limit_rate + 1)); 218 (ngx_msec_t) (- limit * 1000 / r->limit_rate + 1));
219 219
220 c->buffered |= NGX_HTTP_WRITE_BUFFERED; 220 c->buffered |= NGX_HTTP_WRITE_BUFFERED;
221 221
222 return NGX_AGAIN; 222 return NGX_AGAIN;
223 } 223 }
224 224
225 } else { 225 } else {
226 to_send = 0; 226 limit = 0;
227 } 227 }
228 228
229 sent = c->sent; 229 sent = c->sent;
230 230
231 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 231 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
232 "http write filter to send %O", to_send); 232 "http write filter limit %O", limit);
233 233
234 chain = c->send_chain(c, r->out, to_send); 234 chain = c->send_chain(c, r->out, limit);
235 235
236 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 236 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
237 "http write filter %p", chain); 237 "http write filter %p", chain);
238 238
239 if (chain == NGX_CHAIN_ERROR) { 239 if (chain == NGX_CHAIN_ERROR) {
240 c->error = 1; 240 c->error = 1;
241 return NGX_ERROR; 241 return NGX_ERROR;
242 } 242 }
243 243
244 if (to_send) { 244 if (limit) {
245 sent = c->sent - sent; 245 sent = c->sent - sent;
246 c->write->delayed = 1; 246 c->write->delayed = 1;
247 ngx_add_timer(c->write, (ngx_msec_t) (sent * 1000 / r->limit_rate + 1)); 247 ngx_add_timer(c->write, (ngx_msec_t) (sent * 1000 / r->limit_rate + 1));
248 } 248 }
249 249