Welcome! Log In Create A New Profile

Advanced

Re: How to abort subrequest properly?

July 04, 2013 06:44AM
El 04/07/13 02:43, Yichun Zhang (agentzh) escribió:
> Hello!
>
> On Wed, Jul 3, 2013 at 5:37 PM, Marcus Clyne wrote:
>>> If the subrequest uses the upstream mechanism, wouldn't it be safe to just
>>> close the socket of upstream's connection? I'm assuming there would be an
>>> entry in the error log, but is there anything harmful that could come from
>>> it?
>>>
>> And you'd obviously want to finalize the subrequest, probably do something
>> like ngx_http_finalize_request(sr, NGX_OK). I don't think you could just
>> issue this on its own, since I think the subrequest's sockets wouldn't
>> automatically be closed until the main request was finalized (but it's been
>> a while since I've done core hacking, and I can't remember for sure).
>>
> No. For modules based on ngx_http_upstream, the right way to shut it
> down is to call ngx_http_upstream_finalize_request. This is exactly
> what the cleanup handler registered by ngx_http_upstream does (i.e.,
> the gx_http_upstream_cleanup function). And that's why I propose the
> solution of calling the cleanup handler on the subrequest.
>
> Calling ngx_http_finalize_request(sr, NGX_OK) does not really help
> here because the subrequest's cleanup handler that actually shuts down
> the upstream socket (and other resources like the resolver) will not
> be triggered until the main request is cleaned up.
Hence why I was suggesting closing the socket as well as calling
ngx_http_finalize_request. I think the only thing you really need in
the time before the main request finishing is that you don't get any
data on the socket, and your request count is correct. The upstream
request obviously needs to be closed properly, but if the upstream
cleanup function is going to be called anyway by the main request, then
I'm not sure it really makes any difference, and you'd be running
through the cleanup function twice.
>
> On the other hand, calling ngx_http_upstream_finalize_request directly
> on the subrequest should work for strict upstream modules but this is
> just too specific and hacky to be really interesting for any descent
> 3rd-party modules :)
Hacky, for sure but it sounds like this is a custom setup anyway. This
is obviously only going to be useful if the body is one that uses
upstream requests.

Marcus.

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

How to abort subrequest properly?

Marat Dakota 1086 June 30, 2013 07:06AM

Re: How to abort subrequest properly?

Marat Dakota 587 July 02, 2013 08:36PM

Re: How to abort subrequest properly?

Maxim Dounin 634 July 03, 2013 07:56AM

Re: How to abort subrequest properly?

Marat Dakota 595 July 03, 2013 09:20AM

Re: How to abort subrequest properly?

Yichun Zhang (agentzh) 551 July 03, 2013 04:02PM

Re: How to abort subrequest properly?

Marat Dakota 696 July 03, 2013 04:42PM

Re: How to abort subrequest properly?

Eugaia 660 July 03, 2013 08:00PM

Re: How to abort subrequest properly?

Eugaia 688 July 03, 2013 08:40PM

Re: How to abort subrequest properly?

Yichun Zhang (agentzh) 580 July 04, 2013 01:44AM

Re: How to abort subrequest properly?

Eugaia 676 July 04, 2013 06:44AM

Re: How to abort subrequest properly?

Yichun Zhang (agentzh) 683 July 08, 2013 11:40PM



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

Online Users

Guests: 187
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