<div dir="ltr">That's helped. Although, I'm not quite sure that I completely understand what I've done. But it is working as expected now.<div><br></div><div>Thank you!<br><div><br></div><div>--</div><div style>
Marat</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 4, 2013 at 10:42 PM, agentzh <span dir="ltr"><<a href="mailto:agentzh@gmail.com" target="_blank">agentzh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<div class="im"><br>
On Fri, May 3, 2013 at 3:28 PM, Marat Dakota wrote:<br>
> Ok, I need improper way then. Just some way.<br>
><br>
> The problem is that I know "bbb" only after the subrequest is made. And<br>
> subrequest's body is being completely filtered by body filter. So, in fact I<br>
> will not have "ccc", just "aaabbb", but I can't flush "bbb" out because it<br>
> waits for the subrequest to be done.<br>
><br>
<br>
</div>Well, I ran into this problem while working on the "light thread"<br>
model [1] for my ngx_lua module months ago.<br>
<br>
The default Nginx subrequest setup ensures the output order by means<br>
of ngx_http_postpone_filter_module and r->postponed. So we need<br>
workarounds here.<br>
<br>
The solution I end up with is to write my own version of the<br>
ngx_http_subrequest function in ngx_lua and temporarily switch the<br>
current active request (i.e., r->connection->data) to the parent<br>
request every time the parent request is trying to output something<br>
when there's still pending subrequests running (so as to bypass<br>
ngx_http_postpone_filter_module). This works pretty well.<br>
<br>
You can check out the ngx_lua module's source for more details<br>
<br>
<a href="https://github.com/chaoslawful/lua-nginx-module" target="_blank">https://github.com/chaoslawful/lua-nginx-module</a><br>
<br>
especially the file src/ngx_http_lua_subrequest.c.<br>
<br>
Among other things, maybe you want to consider directly using ngx_lua<br>
instead of writing your own Nginx C module for this task.<br>
<br>
Best regards,<br>
-agentzh<br>
<br>
[1] <a href="http://wiki.nginx.org/HttpLuaModule#ngx.thread.spawn" target="_blank">http://wiki.nginx.org/HttpLuaModule#ngx.thread.spawn</a><br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</div></div></blockquote></div><br></div>