So I can answer some of my own questions.
1) to hook really really late, but not REALLY_LAST, it appears that you can
do what test/mod_dialup.c in the source distribution does:
#ifndef APR_HOOK_ALMOST_LAST
#define APR_HOOK_ALMOST_LAST (APR_HOOK_REALLY_LAST - 1)
#endif
static void
dialup_register_hooks(apr_pool_t *p)
{
ap_hook_handler(dialup_handler, NULL, NULL, APR_HOOK_ALMOST_LAST);
}
looking at the macro defs in srclib/apr-util/include/apr_hooks.h it is
clear what is going on.
/* Hook orderings */
/** run this hook first, before ANYTHING */
#define APR_HOOK_REALLY_FIRST (-10)
/** run this hook first */
#define APR_HOOK_FIRST 0
/** run this hook somewhere */
#define APR_HOOK_MIDDLE 10
/** run this hook after every other hook which is defined*/
#define APR_HOOK_LAST 20
/** run this hook last, after EVERYTHING */
#define APR_HOOK_REALLY_LAST 30
combining that definition with the mod_dialup code and documentation it is
clear that all the module hooks are sorted by this value and the higher the
number, the later.
This isn't really supported :) but it appears to work. By the time I get
to my ALMOST_LAST handler I'm pretty sure that nothing else is going to
handle this request and that the default_handler hooked with REALLY_LAST is
just about to be called.
Also, apparently after the request is handled, r->handler is defined to be
the handler that handled the request, or NULL if default_handler did it. I
gather this by the code for %R printing code in the logging code:
from mod_log_config.c
static const char *log_handler(request_rec *r, char *a)
{
return ap_escape_logitem(r->pool, r->handler);
}
So, I THINK that answers my questions. I'm only 90% sure on my guesses as
to what r->handler will be set to by the time the logging handlers are
called - is this canonical? I mean, is this defined behavior or just
accidental? Since mod_log_config seems to depend on it, I'm guessing it is
a reliable thing.
I'm happy to have any of you tell me I'm wrong - if you happen to know any
better.
Fred Clift