<div dir="ltr">Hi all, <div><br></div><div>thanks for the help but after more changes and taking in count your suggestions i am still stuck with the problem (it cannot be in Lua, must be done in C as i am streaming binary data). </div>
<div><br></div><div style>If anyone of you is interested, i will put a budget of 100USD for who is interested into fix the test case as required, for more details send me a private email to discuss the requirements and what is expected as result. </div>
<div style><br></div><div style>thanks, </div><div style> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jul 14, 2013 at 10:57 PM, Yichun Zhang (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 Sun, Jul 14, 2013 at 8:43 PM, Julien Zefi wrote:<br>
><br>
> Sorry by bother you again but i still cannot figure out how some internals<br>
> are not working as i expect. I have take in count your suggestions and wrote<br>
> a new test case (file attached).<br>
><br>
<br>
</div>1. You should simply call ngx_http_output_filter(r, NULL); in your<br>
r->write_event_handler, but you set r->write_event_handler to<br>
ngx_http_test_stream_handler which always emits brand new data. I'm<br>
guessing you don't really understand how the ngx_http_writer and<br>
<div class="im">ngx_http_set_write_handler functions are implemented in the Nginx<br>
</div>core. Look harder.<br>
<br>
2. You should not set r->header_only = 1 in your case because you're<br>
actually sending out the response body. Ensure that you know how a<br>
flag works before you start using it.<br>
<br>
3. Another obvious mistake is that you incorrectly perform<br>
<br>
r->main->count++;<br>
<br>
without decrementing it by calling ngx_http_finalize_request, which<br>
will certainly lead to request hang. Ensure that you understand this<br>
flag before using it.<br>
<div class="im"><br>
> The test case writes 12.3KB of data every 1ms, at some point it will raise<br>
> NGX_AGAIN but from there is not recovering, it keeps in the same state<br>
> forever, do you see any specific problem when handling the exception ?<br>
><br>
<br>
</div>This is trivial to implement by writing some Lua code using ngx_lua module:<br>
<br>
location /t {<br>
content_by_lua '<br>
local message = "..."<br>
for i = 1, 100 do<br>
ngx.print(message)<br>
ngx.flush(true)<br>
ngx.sleep(0.001)<br>
end<br>
';<br>
}<br>
<br>
Maybe you can just use ngx_lua for your purposes without all the pain<br>
of understanding the nginx internals (you seem to lack a lot of<br>
knowledge here). If you insist in writing your own nginx C module,<br>
then just check out how ngx_lua implements all the APIs demonstrated<br>
in the example above. You can also check out the official<br>
documentation of ngx_lua:<br>
<br>
<a href="http://wiki.nginx.org/HttpLuaModule" target="_blank">http://wiki.nginx.org/HttpLuaModule</a><br>
<br>
Best regards,<br>
-agentzh<br>
</blockquote></div><br></div>