httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Teslenko <eugene.tesle...@gmail.com>
Subject Re: Share data between apache modules
Date Sun, 10 May 2015 18:46:04 GMT
It may be any handler module. FastCGI is just for example.
In apache's config it's just Action + SetHandler options.

Thank you very much for your replies and suggestions, it was really an
internal redirect and could get an original request rec through r->prev.


2015-05-10 21:30 GMT+03:00 Yann Ylavic <ylavic.dev@gmail.com>:

> I don't know much about mod_fastcgi (third-party module), but it seems
> that it uses ap_internal_redirect[_handler]().
> This creates a new (redirect) request which is linked with the
> original one through the r->next (= newr) and newr->prev (= r).
> Unlike sub-requests, internal redirects are fully processed and hence
> usually reach the latests hooks (like log_transaction) and the client
> (response),
> The original request is somehow abandonned.
>
> On Sun, May 10, 2015 at 6:26 PM, Eugene Teslenko
> <eugene.teslenko@gmail.com> wrote:
> > mod_a handler function returns "declined" both times it's being called.
> > Here is the source of mod's
> >
> > ===== mod_a.c =====
> >
> > module AP_MODULE_DECLARE_DATA mod_a;
> >
> > static int handler(request_rec *r) {
> >   // if (strcmp(r->handler, "fastcgi-script")) return DECLINED;
> >   apr_table_set(r->notes, "test-var", "test-string");
> >   ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "mod_a[%d]: r_pp=%pp,
> > handler=%s", getpid(), r, r->handler);
> >   return DECLINED;
> > };
> >
> > static void register_hooks(apr_pool_t *p) {
> >   static const char * const asz_before[]={ "mod_fastcgi.c", NULL };
> >   ap_hook_handler(handler, NULL, asz_before, APR_HOOK_MIDDLE);
> > }
> >
> > module AP_MODULE_DECLARE_DATA a_module = {
> >   STANDARD20_MODULE_STUFF,
> >   NULL,
> >   NULL,
> >   NULL,
> >   NULL,
> >   NULL,
> >   register_hooks
> > };
> >
> > ===== mod_b.c =====
> >
> > module AP_MODULE_DECLARE_DATA mod_b;
> >
> > static int log_transaction(request_rec *r) {
> >   ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "mod_b[%d]: test-var=%s,
> > r_pp=%pp, handler=%s", getpid(), apr_table_get(r->notes, "test-var"), r,
> > r->handler);
> >   return DECLINED;
> > }
> >
> > static void register_hooks(apr_pool_t *p) {
> >   static const char * const asz_after[]={ "mod_a.c", NULL };
> >   static const char * const asz_before[]={ "mod_log_config.c", NULL };
> >   ap_hook_log_transaction(log_transaction, asz_after, asz_before,
> > APR_HOOK_MIDDLE);
> > }
> >
> > module AP_MODULE_DECLARE_DATA b_module = {
> >   STANDARD20_MODULE_STUFF,
> >   NULL,
> >   NULL,
> >   NULL,
> >   NULL,
> >   NULL,
> >   register_hooks
> > };
> >
> > ===================
> >
> > Different pointers in the log:
> >
> > [Sun May 10 19:22:05 2015] [...] mod_a[81136]: r_pp=84505f0a0,
> r_main_pp=0,
> > handler=application/x-httpd-php56
> > [Sun May 10 19:22:05 2015] [...] mod_a[81136]: r_pp=845056028,
> r_main_pp=0,
> > handler=fastcgi-script
> > [Sun May 10 19:22:07 2015] [...] mod_b[81136]: test-var=test-string,
> > r_pp=84505f0a0, handler=(null)
> >
> >
> > 2015-05-10 18:04 GMT+03:00 Yann Ylavic <ylavic.dev@gmail.com>:
> >>
> >> What does mod_a handler return?
> >> How do you register it (ap_hook_handler() line)?
> >>
> >>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message