Forum: NGINX Does zero buffer allowed in the output buffer chain?

Posted by Liu Haifeng (Guest)
on 2013-01-30 05:58
(Received via mailing list)
Hi,

I am writing a http handler module, I found when the last buffer in the 
output buffer chain is zero, I'll get an alert in the error log about 
zero output buffer, and the browser will get no response after waiting a 
while, this is not what I am expecting as the buffer chain has data, 
just the last one has zero size. Does this a feature or I missed 
something else?

PS:
nginx version: 1.2.4
gzip option is enabled.
Posted by Jeff Kaufman (Guest)
on 2013-01-30 19:30
(Received via mailing list)
On Tue, Jan 29, 2013 at 10:03 PM, Liu Haifeng <haifeng.813@gmail.com> 
wrote:
>
> I am writing a http handler module, I found when the last buffer in
> the output buffer chain is zero, I'll get an alert in the error log about
> zero output buffer, and the browser will get no response after
> waiting a while, this is not what I am expecting as the buffer
> chain has data, just the last one has zero size.

Why is your last buffer empty?  If you have other buffers in your
chain why do you need an empty buffer?

Regardless, marking your buffer as a sync buffer might be what you want:

    b->pos = b->start = b->end = b->last = NULL;
    b->sync = 1;
    (See 
https://github.com/pagespeed/ngx_pagespeed/blob/ma...)

Jeff
Posted by Maxim Dounin (Guest)
on 2013-01-30 20:13
(Received via mailing list)
Hello!

On Wed, Jan 30, 2013 at 11:03:15AM +0800, Liu Haifeng wrote:

> I am writing a http handler module, I found when the last buffer
> in the output buffer chain is zero, I'll get an alert in the
> error log about zero output buffer, and the browser will get no
> response after waiting a while, this is not what I am expecting
> as the buffer chain has data, just the last one has zero size.
> Does this a feature or I missed something else?

Zero size buffers are not expected to appear in the output chain
except due to some bug, and if they do appear - it's considered to
be a fatal error and results in a connection close.

Normally you should not add empty buffers to the output chain.  If
there are some good reasons why you need to add an empty buffer -
you have to mark the buffer as special, e.g., by setting the
b->sync flag as Jeff Kaufman already suggested.

--
Maxim Dounin
http://nginx.com/support.html
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.