Installing handlers in NGX_HTTP_LOG_PHASE

Maxim Dounin mdounin at mdounin.ru
Wed Dec 23 16:45:42 MSK 2009


Hello!

On Wed, Dec 23, 2009 at 01:52:19PM +0100, Srebrenko Šehić wrote:

> On Wed, Dec 23, 2009 at 11:07 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> > This is somewhat expected as phases array are initialized after
> > reading configuration (see ngx_http.c for details).  The only
> > alternative is SIGBUS, not sure it's better.  :)
> 
> That makes sense. Thanks.
> 
> >> What is the correct approach to conditionally install a handler?
> >
> > In postconfiguration handler.  Nothing stops you from doing it
> > conditionally.
> 
> What I wanted was not to install my handler at all. I guess if I do it
> like you suggest, the handler will have to return NGX_DECLINED if it's
> not supposed to run.

No, I mean you may install handler only if you've found during config 
parsing that it's needed somewhere.

Of course returning NGX_DECLINED will work too.  And actually it 
must be implemented anyway, as phase handlers can't be different 
for different servers/locations, while you probably want perl 
handlers to be configured on per-server and per-location basis.

Maxim Dounin



More information about the nginx-devel mailing list