Re: Current working directory and multi-threaded environments
| From: | Sascha Schumann | Date: | Wed, 15 Mar 2000 18:51:42 +0000 |
| Subject: | Re: Current working directory and multi-threaded environments | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-16847@lists.php.net to get a copy of this message | ||
On Wed, Mar 15, 2000 at 08:32:43PM +0200, Andi Gutmans wrote:
> Hi,
>
> I want to layout a way to fix the issue of the chdir()'s in PHP which
> prevents PHP from working properly in multi-threaded environments.
>
> The solution will probably include doing one getcwd() on startup and
> setting a per-request variable with its value.
>
> >From that point on we'll never use chdir() and getcwd() anymore but
> something like virtual_chdir() and virtual_getcwd() which will behave the
> same way but will not really change the current working directory but will
> adjust the per-request cwd string.
Additionally to this, we need a function which converts a
relative path to an absolute path. Otherwise, every user of
the virtual_* functions will have to reinvent the wheel.
Alternatively, we could provide wrappers around system calls.
The wrappers would convert the arguments passed to them and
call the real system function.
I don't like this particularly, because there are many 3rd
party library functions which we cannot cover all.
What do you think?
> Of course, the file opening functions will be changed to use the new
> functions instead of the original ones and then we should have pretty
> decent virtual current working directories.
>
> Comments? Does anyone have a better solution or see problems with this
> one?
>
> BTW, any idea if Apache changes the current working directory per-request?
I grepped through Apache 2.0 yesterday and there don't seem to
be any request-related getcwd()s or chdir()s.
> I'm not sure if I need to do the real getcwd() per-request or if doing it
> on PHP startup once is good enough.
Why should a threaded web server change its per-process
work directory?
- Sascha