[PATCH] Upstream: fixed $upstream_response_time for filter_finalize + error_page.

Maxim Dounin mdounin at mdounin.ru
Mon Mar 2 19:09:20 UTC 2015


Hello!

On Sun, Feb 15, 2015 at 02:04:03PM -0800, Yichun Zhang (agentzh) wrote:

> Hello!
> 
> On Fri, Feb 13, 2015 at 7:05 AM, Maxim Dounin wrote:
> > Rather, I would suggest something like this:
> >
> > --- a/src/http/ngx_http_upstream.c
> > +++ b/src/http/ngx_http_upstream.c
> > @@ -3744,10 +3744,13 @@ ngx_http_upstream_finalize_request(ngx_h
> >      ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
> >                     "finalize http upstream request: %i", rc);
> >
> > -    if (u->cleanup) {
> > -        *u->cleanup = NULL;
> > -        u->cleanup = NULL;
> > -    }
> > +    if (u->cleanup == NULL) {
> > +        /* the request was already finalized */
> > +        ngx_http_finalize_request(r, NGX_DONE);
>    +        return
> > +    }
> > +
> > +    *u->cleanup = NULL;
> > +    u->cleanup = NULL;
> >
> 
> This patch works for me and yeah it's better. Will you commit it?

I've committed this and another patch related to filter 
finalization, see here:

http://hg.nginx.org/nginx/rev/5abf5af257a7
http://hg.nginx.org/nginx/rev/5f179f344096

In the particular case you've described in the commit log of your 
patch, I would also recommend to avoid using filter finalization.  
When in header filter, it should be enough to just return 
appropriate code instead.  Filter finalization is needed when 
working with a response body, not headers.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list