# Doubt with proxy busy buffer

**URL:** <https://www.ruby-forum.com/t/doubt-with-proxy-busy-buffer/211316>\
**Category:** NGINX\
**Created:** [September 1, 2011, 9:30am UTC](https://www.ruby-forum.com/t/doubt-with-proxy-busy-buffer/211316 "2011-09-01T09:30:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 1, 2011, 9:30am UTC](https://www.ruby-forum.com/t/doubt-with-proxy-busy-buffer/211316/1 "2011-09-01T09:30:53Z")

</div>

Hi,

I write a module for file download, but sometimes it will alert  
“the http output chain is empty while sending to client”.  
And I check the code, it seems that if proxy busy buffer run out,  
write\_filter will always return ngx error.

Is that right?

In function: ngx\_event\_pipe\_write\_to\_downstream(ngx\_event\_pipe\_t \*p)

line 540:

```
    out = NULL;

    if (bsize >= (size_t) p->busy_size) {
        flush = 1;
        goto flush;
    }

```

//If busy size is larger than that value in ngix.conf,  
//out chain will be NULL and goto fulsh  
//and call output\_filter with NULL out chain.

line 617:

```
flush:
    ...............
    rc = p->output_filter(p->output_ctx, out);

```

//So get into ngx\_http\_write\_filter(ngx\_http\_request\_t \*r, ngx\_chain\_t  
\*in),  
//print the alert log and return error.

line: 186

```
if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) {
    if (last) {
        r->out = NULL;
        c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;

        return NGX_OK;
    }

    if (flush) { // flush will never be true, because

```

of NULL in chain  
do {  
r-\>out = r-\>out-\>next;  
} while (r-\>out);

```
        c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;

        return NGX_OK;
    }

    ngx_log_error(NGX_LOG_ALERT, c->log, 0,
                  "the http output chain is empty");

    ngx_debug_point();

    return NGX_ERROR;

```

–  
Best Regard.

Posted at Nginx Forum:

> **[doubt with proxy busy buffer](https://forum.nginx.org/read.php?2,214608,214608#msg-214608)**
>
> Hi, I write a module for file download, but sometimes it will alert "the http output chain is empty while sending to client". And I check the code, it seems that if proxy busy buffer run out, write\_filter will always return ngx error. Is

---

<div class="post-metadata">

**Author:** ![bigplum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@bigplum](https://www.ruby-forum.com/u/bigplum)\
**Post date:** [September 1, 2011, 10:02am UTC](https://www.ruby-forum.com/t/doubt-with-proxy-busy-buffer/211316/2 "2011-09-01T10:02:20Z")

</div>

Hello!

On Thu, Sep 01, 2011 at 03:30:34AM -0400, bigplum wrote:

> Hi,
> 
> I write a module for file download, but sometimes it will alert  
> “the http output chain is empty while sending to client”.  
> And I check the code, it seems that if proxy busy buffer run out,  
> write\_filter will always return ngx error.
> 
> Is that right?

If ngx\_http\_write\_filter() is called with NULL, r-\>out must not be  
empty. If it’s empty - this means that buffer(s) to flush  
disappeared somewhere, and alert will warn you about this problem.

Maxim D.

---

<div class="post-metadata">

**Author:** ![bigplum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@bigplum](https://www.ruby-forum.com/u/bigplum)\
**Post date:** [September 1, 2011, 10:17am UTC](https://www.ruby-forum.com/t/doubt-with-proxy-busy-buffer/211316/3 "2011-09-01T10:17:45Z")

</div>

Thanks to Maxim, I make a mistake that do not read the r-\>out  
statements.  
The r-\>out is NULL, so something goes wrong.

Posted at Nginx Forum:

> **[Re: doubt with proxy busy buffer](https://forum.nginx.org/read.php?2,214608,214610#msg-214610)**
>
> Hi, I write a module for file download, but sometimes it will alert "the http output chain is empty while sending to client". And I check the code, it seems that if proxy busy buffer run out, write\_filter will always return ngx error. Is
