Welcome! Log In Create A New Profile

Advanced

Re: terminate a connection after sending headers

September 04, 2014 04:38PM
Thank you very much Maxim ! this works !

However, I bumped into a new problem, I use 2 different types of asyncronous operations in my code - file I/O and http requests. When I call ngx_http_run_posted_requests from the aio callback it works well, but when I call it from the HTTP completion callback it actually makes the request hang.
I can see that it calls ngx_http_upstream_check_broken_connection in r->write_event_handler(r). I guess that in this case I should let ngx_http_run_posted_requests run from the upstream module instead of calling it myself.

So my questions are:
1. Is there a simple rule that dictates when I should call ngx_http_run_posted_requests and when I should not ?
I can work around the problem by doing something like 'if called from the aio callback call ngx_http_run_posted_requests' otherwise, don't call, but that doesn't feel like the correct solution.
2. A simpler solution that seems to work for me, is to call ngx_http_run_posted_requests only when I see that r->main->count is one (before finalize). But I don't know if that solution makes any sense - is there any relation between these posted_requests and the request count ?
My understanding (before reading your reply :)) was that whenever I do something asynchronous I must increment the count, whenever I call finalize_request the count is decremented and once the count reaches zero the request is terminated. So, what I'm missing is why the termination of the request has to be deferred via posted requests - couldn't ngx_http_terminate_request just close the request only when it sees the count reached zero instead ?

Thanks again for all your help, I really appreciate it !

Eran
Subject Author Posted

terminate a connection after sending headers

erankor2 September 01, 2014 05:25PM

Re: terminate a connection after sending headers

Maxim Dounin September 02, 2014 09:10AM

Re: terminate a connection after sending headers

erankor2 September 03, 2014 10:10AM

Re: terminate a connection after sending headers

Maxim Dounin September 03, 2014 09:12PM

Re: terminate a connection after sending headers

erankor2 September 04, 2014 04:38PM

Re: terminate a connection after sending headers

Maxim Dounin September 05, 2014 12:36AM

Re: terminate a connection after sending headers

erankor2 September 07, 2014 04:49PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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