# Does zero buffer allowed in the output buffer chain?

**URL:** <https://www.ruby-forum.com/t/does-zero-buffer-allowed-in-the-output-buffer-chain/225793>\
**Category:** NGINX\
**Created:** [January 30, 2013, 5:58am UTC](https://www.ruby-forum.com/t/does-zero-buffer-allowed-in-the-output-buffer-chain/225793 "2013-01-30T05:58:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSkonishi\_takurou\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@SSkonishi\_takurou\_S](https://www.ruby-forum.com/u/SSkonishi_takurou_S)\
**Post date:** [January 30, 2013, 5:58am UTC](https://www.ruby-forum.com/t/does-zero-buffer-allowed-in-the-output-buffer-chain/225793/1 "2013-01-30T05:58:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![landlord01](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@landlord01](https://www.ruby-forum.com/u/landlord01)\
**Post date:** [January 30, 2013, 7:30pm UTC](https://www.ruby-forum.com/t/does-zero-buffer-allowed-in-the-output-buffer-chain/225793/2 "2013-01-30T19:30:47Z")

</div>

On Tue, Jan 29, 2013 at 10:03 PM, Liu H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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 

```

[incubator-pagespeed-ngx/src/ngx\_pagespeed.cc at master · apache/incubator-pagespeed-ngx · GitHub](https://github.com/pagespeed/ngx_pagespeed/blob/master/src/ngx_pagespeed.cc#L121))

Jeff

---

<div class="post-metadata">

**Author:** ![landlord01](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@landlord01](https://www.ruby-forum.com/u/landlord01)\
**Post date:** [January 30, 2013, 8:13pm UTC](https://www.ruby-forum.com/t/does-zero-buffer-allowed-in-the-output-buffer-chain/225793/3 "2013-01-30T20:13:28Z")

</div>

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.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
