handle NGX_AGAIN properly
Wandenberg Peixoto
wandenberg at gmail.com
Sat Jan 3 23:57:32 UTC 2015
Hi Julien,
I was having the same problem with NGX_AGAIN and could solved it.
Did you fix your problem?
I can try to help you.
Regards,
Wandenberg
On Thu, Jul 18, 2013 at 1:37 AM, Julien Zefi <jzefip at gmail.com> wrote:
> Hi all,
>
> 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).
>
> 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.
>
> thanks,
>
>
>
> On Sun, Jul 14, 2013 at 10:57 PM, Yichun Zhang (agentzh) <
> agentzh at gmail.com> wrote:
>
>> Hello!
>>
>> On Sun, Jul 14, 2013 at 8:43 PM, Julien Zefi wrote:
>> >
>> > Sorry by bother you again but i still cannot figure out how some
>> internals
>> > are not working as i expect. I have take in count your suggestions and
>> wrote
>> > a new test case (file attached).
>> >
>>
>> 1. You should simply call ngx_http_output_filter(r, NULL); in your
>> r->write_event_handler, but you set r->write_event_handler to
>> ngx_http_test_stream_handler which always emits brand new data. I'm
>> guessing you don't really understand how the ngx_http_writer and
>> ngx_http_set_write_handler functions are implemented in the Nginx
>> core. Look harder.
>>
>> 2. You should not set r->header_only = 1 in your case because you're
>> actually sending out the response body. Ensure that you know how a
>> flag works before you start using it.
>>
>> 3. Another obvious mistake is that you incorrectly perform
>>
>> r->main->count++;
>>
>> without decrementing it by calling ngx_http_finalize_request, which
>> will certainly lead to request hang. Ensure that you understand this
>> flag before using it.
>>
>> > The test case writes 12.3KB of data every 1ms, at some point it will
>> raise
>> > NGX_AGAIN but from there is not recovering, it keeps in the same state
>> > forever, do you see any specific problem when handling the exception ?
>> >
>>
>> This is trivial to implement by writing some Lua code using ngx_lua
>> module:
>>
>> location /t {
>> content_by_lua '
>> local message = "..."
>> for i = 1, 100 do
>> ngx.print(message)
>> ngx.flush(true)
>> ngx.sleep(0.001)
>> end
>> ';
>> }
>>
>> Maybe you can just use ngx_lua for your purposes without all the pain
>> of understanding the nginx internals (you seem to lack a lot of
>> knowledge here). If you insist in writing your own nginx C module,
>> then just check out how ngx_lua implements all the APIs demonstrated
>> in the example above. You can also check out the official
>> documentation of ngx_lua:
>>
>> http://wiki.nginx.org/HttpLuaModule
>>
>> Best regards,
>> -agentzh
>>
>
>
> _______________________________________________
> 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/20150103/a1f4c8ca/attachment.html>
More information about the nginx-devel
mailing list