Doubt with proxy busy buffer

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:

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.

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: