As it seems that mod_perl only manages Perl interpreters per VHOST, is there any way I can influence which cloned interpreter mod_perl selects to process a request? I've read through the configurable scopes and had a look into "modperl_interp_select" in the source and I could see that if a request already has a interpreter associated, that one is selected by mod_perl.
else if (r) {
if (is_subrequest && (scope == MP_INTERP_SCOPE_REQUEST)) {
[...]
}
else {
p = r->pool;
get_interp(p);
}
I would like to add some kind of handler before mod_perl selects an interpreter to process a request and then select an interpreter to assign it to the request myself, based on different criteria included in the request.
But I'm having trouble to understand if such a handler can exist at all or if everything regarding a request is already processed by a selected interpreter of mod_perl.
Additionally, I can see APR::Pool-API, but it doesn't seem to provide the capability to set some user data on a current pool object, which is what mod_perl reads by "get_interp".
Could anyone help me on that? Thanks!
A bit on the background: I have a dir structure in cgi-bin like the following:
cgi-bin
software1
customer1
*.cgi
*.pm
customer2
*.cgi
*.pm
software2
customer1
*.cgi
*.pm
customer2
*.cgi
*.pm
Each customer uses a private copy of the software and the software is using itself, e.g. software1 of customer1 may talk to software2 of customer1 by loading some special client libs of software2 into it's own Perl interpreter. To get things more complicated, software2 may even bring general/common parts of software1 with it's own private installation by using svn:external. So I have a lot of the same software with the same Perl packages in one VHOST and I can't guarantee that all of those private installation always have the same version level.
It's quite a mixup, but which is known to work under the rules we have within the same Perl interpreter.
But now comes mod_perl, clones interpreters as needed and reuses them for requests into whichever sub dir of cgi-bin it likes and in this case things will break, because suddenly the interpreter already processed software1 of customer1 and should now process software2 of customer2, which uses common packages of software1, which already where loaded by the Perl interpreter before and are used because of %INC instead of the private packages of software2 and such...
Yes, there are different ways to deal with that, like VHOSTs and sub domains persoftware or customer or whatever, but I would like to check different ways of keeping one VHOST and the current directory structure, just by using what mod_perl or Apache httpd provides. And one way would be if I could tell mod_perl to always use the same Perl interpreter for requests to the same directory. This way mod_perl would create it's pool of interpreters and I would be responsible to select each of them per directory.
reverse proxy
for certain URLs (each your CGI script has its own URL), and will run for each script an own Plack based server (on different ports) using CGI::Emulate::PSGI or CGI::PSGI. So, in short for each CGI-script will run one separated Plack(perl) server on its own port in totally isolated (but httpd-proxied) environment. – jm666../cgi-bin
(e.g. many scripts in one directory) here is the Plack::App::CGIBin. But, of course, if you must stuck with apache (and can't use native perl-plack/web-server) such starman and/or others, the easier(?) way will be patch mod_perl sources and maintain the patched version. ;) It was not a recommendation (not enough details) - only an comment. (I'm an Plack fan) :) – jm666