Stas Bekman wrote:
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};
see also have_apache_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.
I think this is on the right track.
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.
this is one of those fuzzy areas. in general, I prefer access to the raw ap_* methods. however,
Apache->mpm_query(APR::MPMQ_IS_THREADED);
seems a bit awkward, and we can't autogenerate it anyway due to the way it returns information back (at least not easily, I wouldn't think). also, what it returns isn't just a yes or no - you'd need to compare the result to AP_MPMQ_DYNAMIC, for instance, to see if you were in an mpm like worker or win32.
so, I'm more in favor of the
Apache->mpm_is_threaded;
approach (keeping the order of wording the same as the constant), with mod_perl adding the sugar to make the API easy.
this all assumes that what is important is whether the mpm is threaded or not, not whether the threads are fixed in number or can grow, etc (which seems reasonable to me).
--Geoff
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html