Reorder output chain when subrequests are used
Marat Dakota
dakota at brokenpipe.ru
Sun May 5 21:08:09 UTC 2013
That's helped. Although, I'm not quite sure that I completely understand
what I've done. But it is working as expected now.
Thank you!
--
Marat
On Sat, May 4, 2013 at 10:42 PM, agentzh <agentzh at gmail.com> wrote:
> Hello!
>
> On Fri, May 3, 2013 at 3:28 PM, Marat Dakota wrote:
> > Ok, I need improper way then. Just some way.
> >
> > The problem is that I know "bbb" only after the subrequest is made. And
> > subrequest's body is being completely filtered by body filter. So, in
> fact I
> > will not have "ccc", just "aaabbb", but I can't flush "bbb" out because
> it
> > waits for the subrequest to be done.
> >
>
> Well, I ran into this problem while working on the "light thread"
> model [1] for my ngx_lua module months ago.
>
> The default Nginx subrequest setup ensures the output order by means
> of ngx_http_postpone_filter_module and r->postponed. So we need
> workarounds here.
>
> The solution I end up with is to write my own version of the
> ngx_http_subrequest function in ngx_lua and temporarily switch the
> current active request (i.e., r->connection->data) to the parent
> request every time the parent request is trying to output something
> when there's still pending subrequests running (so as to bypass
> ngx_http_postpone_filter_module). This works pretty well.
>
> You can check out the ngx_lua module's source for more details
>
> https://github.com/chaoslawful/lua-nginx-module
>
> especially the file src/ngx_http_lua_subrequest.c.
>
> Among other things, maybe you want to consider directly using ngx_lua
> instead of writing your own Nginx C module for this task.
>
> Best regards,
> -agentzh
>
> [1] http://wiki.nginx.org/HttpLuaModule#ngx.thread.spawn
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130506/1a2aea03/attachment.html>
More information about the nginx-devel
mailing list