Does zero buffer allowed in the output buffer chain?

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.

On Tue, Jan 29, 2013 at 10:03 PM, Liu H. [email protected]
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/master/src/ngx_pagespeed.cc#L121)

Jeff

Hello!

On Wed, Jan 30, 2013 at 11:03:15AM +0800, Liu H. 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 D.
http://nginx.com/support.html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs