Welcome! Log In Create A New Profile

Advanced

Re: Rate Limit with multiple subrequests

Maxim Dounin
May 03, 2011 08:36AM
Hello!

On Mon, May 02, 2011 at 07:14:46PM -0400, Umesh Sirsiwal wrote:

> ngx_http_write_filter module has the following code for rate limit.
> if (r->limit_rate) {
> limit = r->limit_rate * (ngx_time() - r->main->start_sec + 1)
> - (c->sent - clcf->limit_rate_after);
>
> Looking at the code, it seems the start_sec is overwritten for each
> subrequest.
> ngx_int_t
> ngx_http_subrequest(ngx_http_request_t *r,
> ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
> ngx_http_post_subrequest_t *ps, ngx_uint_t flags)
>
> tp = ngx_timeofday();
> r->start_sec = tp->sec;
> r->start_msec = tp->msec;
>
> The implication is that the rate limit is off when we have multiple
> subrequests. Shouldn't the above be:
> sr->start_sec = tp->sec;
> sr->start_msec = tp->msec;

Yes, thank you for your report. Incorrect setting of
r->start_sec/msec was already discussed in russian mailing
list[1], fix is in 1.0.1.

[1] http://nginx.org/pipermail/nginx-ru/2011-April/040677.html

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Rate Limit with multiple subrequests

Umesh Sirsiwal 1635 May 02, 2011 07:12PM

Re: Rate Limit with multiple subrequests

Maxim Dounin 672 May 03, 2011 08:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 86
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready