doubt with proxy busy buffer

bigplum nginx-forum at
Thu Sep 1 07:30:34 UTC 2011


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: 

        rc = p->output_filter(p->output_ctx, out);

//So get into ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t
//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");


        return NGX_ERROR;

Best Regard.

Posted at Nginx Forum:,214608,214608#msg-214608

More information about the nginx mailing list