httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject Re: Share data between apache modules
Date Sun, 10 May 2015 18:30:00 GMT
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
View raw message