perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject $r->chdir_file for registry revistited
Date Wed, 22 May 2002 17:44:22 GMT
i'm working on the issue with chdir, which we cannot use in 2.0, because 
it's not thread-safe.

The issue of require() and friends when they use relative paths is 
easily resolved by pushing the script's dir as the first element of @INC.

The big issue is the open() call when it tries to open a file relative 
to the script's dir. We could override open() but its args are very 
complex which will require an expensive parser, so it's a no-no. A 
simpler solution is to tell the user to use full paths everywhere. This 
can be done in a portable way using this code

use File::Basename ();
my $cwd = File::Basename::dirname($0);

we could supply a wrapper  to shorten things and cache the value for 
registry scripts to speed things up, so the user will call:

ModPerl::Registry::cwd();

to make it back-compatible with 1.x we need to include this wrapper at 
least in 1.27 that's about to be released. PerlRun and other scripts can 
still use ModPerl::Registry::cwd();

or should we use some longer sub name and export it into the script's 
namespace?

In any case if the wrapper is used, the scripts won't work under 
mod_cgi. On the other hand if File::Basename::dirname() is used 
explicitly the script will still work with mod_cgi.

The worst thing about this workaround, no matter how we implement it, is 
that users will have to modify their code to make this work. So the cool 
idea of "run your scripts unaltered" doesn't work any more :(

May be we can still have a special mode in which chdir() is performed if 
running under non-threaded mpm? For those who need a transition period?

__________________________________________________________________
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


Mime
View raw message