Welcome! Log In Create A New Profile

Advanced

Re: ngx_http_request_t's subrequests is what meaning be?

Maxim Dounin
July 01, 2010 10:18AM
Hello!

On Thu, Jul 01, 2010 at 08:08:42PM +0800, BoBo wrote:

> hi all.
>
> I am reading nginx's source(version is 0.7.66), but i don't understand this
> section:
>
> 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)
> {
> ngx_connection_t *c;
> ngx_http_request_t *sr;
> ngx_http_core_srv_conf_t *cscf;
> ngx_http_postponed_request_t *pr, *p;
>
> //i know subrequests's default is NGX_HTTP_MAX_SUBREQUESTS + 1 = 51;
> r->main->subrequests--;
>
> //when subrequests is 0?
> if (r->main->subrequests == 0) {
> ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
> "subrequests cycle while processing \"%V\"", uri);
> r->main->subrequests = 1;
> return NGX_ERROR;
> }
> ....................................................................
>
> //why subrequests need plus plus?
> r->main->subrequests++;
>
> *psr = sr;
>
> return ngx_http_post_request(sr);
> }
>
> the problem is after call ngx_http_subrequest and r->main->subrequests will
> not change(because subrequests-- and then ++), so when subrequests is 0?

Right now - it would never be 0 (and this strikes badly as long as
you issue > 255 subrequests, as r->main->counter overflows). This
logic was introduced for older subrequest implementation where
subrequests were completed directly. Subrequest processing was
changed in 0.7.25 and this subrequests-- and subrequests++ no
longer make sense.

I've posted a patch a while ago which moves r->main->subrequests++
into request finalization, see here (in Russian):

http://nginx.org/pipermail/nginx-ru/2010-February/032184.html

Maxim Dounin

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

ngx_http_request_t's subrequests is what meaning be?

BoBo July 01, 2010 08:16AM

Re: ngx_http_request_t's subrequests is what meaning be?

BoBo July 01, 2010 08:38AM

Re: ngx_http_request_t's subrequests is what meaning be?

Maxim Dounin July 01, 2010 10:18AM

Re: ngx_http_request_t's subrequests is what meaning be?

BoBo July 01, 2010 11:08PM

Re: ngx_http_request_t's subrequests is what meaning be?

Maxim Dounin July 02, 2010 04:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready