<div dir="ltr">Hi Julien,<div><br></div><div>I was having the same problem with NGX_AGAIN and could solved it.</div><div>Did you fix your problem?</div><div>I can try to help you.</div><div><br></div><div>Regards,</div><div>Wandenberg</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 18, 2013 at 1:37 AM, Julien Zefi <span dir="ltr"><<a href="mailto:jzefip@gmail.com" target="_blank">jzefip@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>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><br></div><div>thanks, </div><div> </div></div><div class="HOEnZb"><div class="h5"><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><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>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><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>
</div></div><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></blockquote></div><br></div>