You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2003/10/02 17:06:57 UTC

[Fwd: Re: map_to_storage hook question..]

this is kinda cool, and would eliminate some of the issues mod_perl had with 
the core translate handler in 1.3 (namely that it runs no matter what, 
wasting processing for mod_perl-only back-ends)

any reason why we don't have a PerlMapToStorageHandler?

I saw run_map_to_storage in Apache::HookRun, but that didn't look like the 
same thing.

anyway, I'll stick all the required mod_perl glue in place unless there is a 
specific reason it's not there already.

--Geoff

-------- Original Message --------
Subject: Re: map_to_storage hook question..
Date: Wed, 01 Oct 2003 23:07:27 -0400
From: Bill Stoddard <bi...@wstoddard.com>
Reply-To: dev@httpd.apache.org
To: dev@httpd.apache.org
References: <03...@epnet>

Esteban Pizzini wrote:
> Hi,
> 
> Anybody can explain me what map_to_storage hook does?? or where can I find
> and example of its use??
>  
> Thank You!,
>  Esteban
>  
> 
One use of map_to_storage is to bypass directory walk and file walk if
your handler module -knows for certain- that the request is not being
served out of the Apache file space. Your module would register a
translate_name hook, a map_to_storage hook and a handler. It inspects
the URL in translate_name then decides whether it will serve the content
or not. If it decides it will serve its own content (but not out of the
Apache file system) your module drops a hint in r->request_config (from
translate_name) that map_to_storage will look for. If map_to_storage
sees the hint, it returns OK which causes the core_map_to_storage hook
to be bypassed. At this point, your handler dang well better not DECLINE
the request if it decided in translate_name that it was going to serve
the request.

Bill




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>> But we could internally shortcut map_to_storage if transhandler has 
>> returned OK, no? Do we really need yet another hook?
> 
> 
> I'm kinda against any kind of magic here.  apache separates the hooks, 
> probably for a good reason (even if we can't see it at the moment).
> 
>>
>> Would it still be an added value if we can make PerlTransHandler 
>> behave like 1.3 did?
> 
> 
> perhaps, but I need to think about it more.  the filename errors from 
> map_to_storage have always bothered me, so we need to decide whether we 
> tell  API users to set a bogus filename, or write a 
> PerlMapToStorageHandler, or live with the errors.  or we have mod_perl 
> do some action-at-a-distance thing.
> 
> lemme think about it some.  but I'm almost always in favor of a 1 to 1 
> mapping of Apache hooks and mod_perl hooks, as it keeps with the idea 
> that mod_perl is Perl access to the C API, rather than some magic 
> inbetween API all it's own.

Sounds good. Just remember that we should also try to keep backcompatibility 
with mp1 and follow the least surprise approach. If we fix that behavior in 
mp2 it'll work as before for people moving to mp1. If we provide a new hook 
they will need to change things. and if they need to have the same module 
working in mp1 and mp2 they won't be able to use the same config, which will 
be a pain. I'm not sure what's the best approach. It's possible that if we 
introduce this hook in mp2 we should also do that in mp1.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> But we 
> could internally shortcut map_to_storage if transhandler has returned 
> OK, no? Do we really need yet another hook?

I'm kinda against any kind of magic here.  apache separates the hooks, 
probably for a good reason (even if we can't see it at the moment).

> 
> Would it still be an added value if we can make PerlTransHandler behave 
> like 1.3 did?

perhaps, but I need to think about it more.  the filename errors from 
map_to_storage have always bothered me, so we need to decide whether we tell 
  API users to set a bogus filename, or write a PerlMapToStorageHandler, or 
live with the errors.  or we have mod_perl do some action-at-a-distance thing.

lemme think about it some.  but I'm almost always in favor of a 1 to 1 
mapping of Apache hooks and mod_perl hooks, as it keeps with the idea that 
mod_perl is Perl access to the C API, rather than some magic inbetween API 
all it's own.

--Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>>> well, from the sounds of Bill's email, map_to_storage is going to run 
>>> even if you return OK from a PerlTransHandler, and it's 
>>> map_to_storage that consumes the overhead of stat'ing the filesystem 
>>> for static files.
>>>
>>> but I could be misunderstanding - I haven't looked at the code yet.
>>
>>
>>
>> I think not. That's precisely the point of:
>>
>>   PerlTransHandler Apache::Constants::OK
> 
> 
> yes, I'm aware of that.
> 
>>
>> which causes map_to_storage to skip. I think it's the same in mp2.
> 
> 
> apparently it isn't.  I modified mod_example.c to hook map_to_storage 
> and returned OK from a PerlTransHandler.  mod_example's translate 
> handler is not called, but map_to_storage still is.

Right,

   PerlTransHandler Apache::OK

without setting r->filename was segfaulting in httpd-2.0, I think it has been 
fixed, but I don't remember whether I have tested it since then. So it's a 
different behavior in httpd-2.0, since httpd-1.3 then. But we could internally 
shortcut map_to_storage if transhandler has returned OK, no? Do we really need 
yet another hook?

>>> but regardless, as with all things apache, if it exists we should 
>>> probably open it up :)
>>
>>
>>
>> If it's of any use to us, sure, otherwise, not really. IMHO, 
>> PerlTransHandler is just fine for this.
> 
> 
> looks like it will be value added.  I'll put something together soonish 
> for this.

Would it still be an added value if we can make PerlTransHandler behave like 
1.3 did?


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> well, from the sounds of Bill's email, map_to_storage is going to run 
>> even if you return OK from a PerlTransHandler, and it's map_to_storage 
>> that consumes the overhead of stat'ing the filesystem for static files.
>>
>> but I could be misunderstanding - I haven't looked at the code yet.
> 
> 
> I think not. That's precisely the point of:
> 
>   PerlTransHandler Apache::Constants::OK

yes, I'm aware of that.

> 
> which causes map_to_storage to skip. I think it's the same in mp2.

apparently it isn't.  I modified mod_example.c to hook map_to_storage and 
returned OK from a PerlTransHandler.  mod_example's translate handler is not 
called, but map_to_storage still is.

> 
>> but regardless, as with all things apache, if it exists we should 
>> probably open it up :)
> 
> 
> If it's of any use to us, sure, otherwise, not really. IMHO, 
> PerlTransHandler is just fine for this.

looks like it will be value added.  I'll put something together soonish for 
this.

--Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> 
> Stas Bekman wrote:
> 
>> Geoffrey Young wrote:
>>
>>> this is kinda cool, and would eliminate some of the issues mod_perl 
>>> had with the core translate handler in 1.3 (namely that it runs no 
>>> matter what, wasting processing for mod_perl-only back-ends)
>>>
>>> any reason why we don't have a PerlMapToStorageHandler?
>>
>>
>>
>> What's wrong with doing that in PerlTransHandler?
> 
> 
> well, from the sounds of Bill's email, map_to_storage is going to run 
> even if you return OK from a PerlTransHandler, and it's map_to_storage 
> that consumes the overhead of stat'ing the filesystem for static files.
> 
> but I could be misunderstanding - I haven't looked at the code yet.

I think not. That's precisely the point of:

   PerlTransHandler Apache::Constants::OK

which causes map_to_storage to skip. I think it's the same in mp2.

> but regardless, as with all things apache, if it exists we should 
> probably open it up :)

If it's of any use to us, sure, otherwise, not really. IMHO, PerlTransHandler 
is just fine for this.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
> Geoffrey Young wrote:
> 
>> this is kinda cool, and would eliminate some of the issues mod_perl 
>> had with the core translate handler in 1.3 (namely that it runs no 
>> matter what, wasting processing for mod_perl-only back-ends)
>>
>> any reason why we don't have a PerlMapToStorageHandler?
> 
> 
> What's wrong with doing that in PerlTransHandler?

well, from the sounds of Bill's email, map_to_storage is going to run even 
if you return OK from a PerlTransHandler, and it's map_to_storage that 
consumes the overhead of stat'ing the filesystem for static files.

but I could be misunderstanding - I haven't looked at the code yet.

but regardless, as with all things apache, if it exists we should probably 
open it up :)

--Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: map_to_storage hook question..]

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> this is kinda cool, and would eliminate some of the issues mod_perl had 
> with the core translate handler in 1.3 (namely that it runs no matter 
> what, wasting processing for mod_perl-only back-ends)
> 
> any reason why we don't have a PerlMapToStorageHandler?

What's wrong with doing that in PerlTransHandler?

> I saw run_map_to_storage in Apache::HookRun, but that didn't look like 
> the same thing.
> 
> anyway, I'll stick all the required mod_perl glue in place unless there 
> is a specific reason it's not there already.
> 
> --Geoff
> 
> -------- Original Message --------
> Subject: Re: map_to_storage hook question..
> Date: Wed, 01 Oct 2003 23:07:27 -0400
> From: Bill Stoddard <bi...@wstoddard.com>
> Reply-To: dev@httpd.apache.org
> To: dev@httpd.apache.org
> References: <03...@epnet>
> 
> Esteban Pizzini wrote:
> 
>> Hi,
>>
>> Anybody can explain me what map_to_storage hook does?? or where can I 
>> find
>> and example of its use??
>>  
>> Thank You!,
>>  Esteban
>>  
>>
> One use of map_to_storage is to bypass directory walk and file walk if
> your handler module -knows for certain- that the request is not being
> served out of the Apache file space. Your module would register a
> translate_name hook, a map_to_storage hook and a handler. It inspects
> the URL in translate_name then decides whether it will serve the content
> or not. If it decides it will serve its own content (but not out of the
> Apache file system) your module drops a hint in r->request_config (from
> translate_name) that map_to_storage will look for. If map_to_storage
> sees the hint, it returns OK which causes the core_map_to_storage hook
> to be bypassed. At this point, your handler dang well better not DECLINE
> the request if it decided in translate_name that it was going to serve
> the request.
> 
> Bill
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org


-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org