Subrequest without returning to nginx

Alfred Sawaya alfred at
Tue May 4 15:25:02 UTC 2021

Ah, I felt it. I needed to read it from someone that knows better.

So... Big refactor time :)

Thank you Maxim

On 04/05/2021 16:59, Maxim Dounin wrote:
> Hello!
> On Tue, May 04, 2021 at 04:11:34PM +0200, Alfred Sawaya wrote:
>> I am currently converting an Apache module to Nginx. This module uses
>> subrequests and needs (for now) to execute the subrequest without
>> unwinding the stack (ie without returning to nginx).
>> I tried to call ngx_http_run_posted_requests by hand, but it does not
>> work as the upstream socket needs to get polled some time.
>> So I wonder, is there any way to do this ?
> No.  Since nginx is event-driven, you essentially cannot do 
> anything without returning control back to nginx to execute the 
> event loop.
>> Of course I know that I shouldn't do it like this, but the current
>> module is not reentrant and poorly architectured. I will eventually
>> refactor it but later.
> You may want to start with throwing away the module, and writing 
> another one for nginx from scratch.  "Converting" rarely works 
> even for simple and well-written modules.

More information about the nginx-devel mailing list