Elizabeth Mattijsen wrote: [...]
So is there a way to find out whether a prefork MPM is being used in mod_perl while running a Perl script?
In the test suite we have this information via:
require Apache::Test; my $mpm = Apache::Test::config()->{vars}->{mpm};
but I think what you really want to know whether the server is threaded or not, since you have several mpms which correspond which implement threads, and it's possible that there will be other non-threaded mpms, besides prefork. So I think you are after:
Apache->is_mpm_threaded();
At the moment we don't have such a method in Perl. Apache has the C method ap_mpm_query() which we use
grep -Inr ap_mpm_query src
src/modules/perl/mod_perl.c:458: ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
which is then set into a global internal variable, which we could expose in perl similar to Apache->server, which also gives you the global main server object.
Though it seems that Doug has planned a whole Apache::MPM class, whose autogeneration is disabled at the moment (see xs/maps/apache_functions.map:492), so I'm not sure whether it's better to start exposing Apache::MPM methods and give a raw access to ap_query_mpm.
Ideas?
Meanwhile you can query apxs if you have it:
/home/stas/httpd/prefork/bin/apxs -q MPM_NAME prefork
Or use it via Apache::Build which hopefully will give you the right info (it stores the info during the mod_perl.so build, if someone modifies things later, without rebuilding mod_perl, it's possible that you may get incorrect info). that's why we shouldn't rely on this info if we can and use a run-time query of httpd that runs at the moment.
But temprorary you can use:
% perl-5.8.2-ithread -MApache2 -le 'use Apache::Build; \ print Apache::Build->build_config->mpm_is_threaded'
(it's not threaded so it returns false).
and if you want the mpm name:
% perl-5.8.2-ithread -MApache2 -le 'use Apache::Build; \ print Apache::Build->build_config->mpm_name' prefork
Again, this information could be wrong if you have more than one build of mod_perl under the same perl tree. Consider: you build and install mod_perl.so against a threaded httpd and then you build and install another one against a non-threaded httpd. Apache::Build will report the info about the latest one. This is exactly what happens on my system, where I have both versions built with the same perl.
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html