~ubuntu-branches/debian/squeeze/nginx/squeeze

« back to all changes in this revision

Viewing changes to src/http/ngx_http_write_filter_module.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-11-08 09:53:46 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20091108095346-yt4eypw2l176tl53
Tags: 0.7.63-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
ngx_int_t
47
47
ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
48
48
{
49
 
    off_t                      size, sent, limit;
 
49
    off_t                      size, sent, nsent, limit;
50
50
    ngx_uint_t                 last, flush;
51
51
    ngx_msec_t                 delay;
52
52
    ngx_chain_t               *cl, *ln, **ll, *chain;
210
210
    }
211
211
 
212
212
    if (r->limit_rate) {
213
 
        limit = r->limit_rate * (ngx_time() - r->start_sec + 1) - c->sent;
 
213
        limit = r->limit_rate * (ngx_time() - r->start_sec + 1)
 
214
                - (c->sent - clcf->limit_rate_after);
214
215
 
215
216
        if (limit <= 0) {
216
217
            c->write->delayed = 1;
245
246
    }
246
247
 
247
248
    if (r->limit_rate) {
248
 
        delay = (ngx_msec_t) ((c->sent - sent) * 1000 / r->limit_rate + 1);
 
249
 
 
250
        nsent = c->sent;
 
251
 
 
252
        if (clcf->limit_rate_after) {
 
253
 
 
254
            sent -= clcf->limit_rate_after;
 
255
            if (sent < 0) {
 
256
                sent = 0;
 
257
            }
 
258
 
 
259
            nsent -= clcf->limit_rate_after;
 
260
            if (nsent < 0) {
 
261
                nsent = 0;
 
262
            }
 
263
        }
 
264
 
 
265
        delay = (ngx_msec_t) ((nsent - sent) * 1000 / r->limit_rate + 1);
249
266
 
250
267
        if (delay > 0) {
251
268
            c->write->delayed = 1;