Tidbits | Jan. 24, 2006

Apache::DB, Apache::DProf, and Apache::SmallProf updates

by Frank Wiles

Recently it came to my attention that there were some fairly serious bugs in some of the CPAN modules I maintain. Stas Bekman was trying to use Apache::DProf to profile the performance of one of his projects and could not get it to work.

The problem essentially boiled down to the generally accepted best practice at how to determine if your code is running in mod_perl 1.x or 2.x doesn't work in all cases in all environments. This is because of when the $mod_perl or $mod_perl2 modules are loaded in relation to the Apache lifecycle.

Instead of using:

use constant MP2 = > eval { require mod_perl; $mod_perl::VERSION > 1.99 };

We're going to use:

use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 );

Because this environment variable is guaranteed to always be available and accurate.

I've uploaded a new distribution of these modules to CPAN just now and it should make it to your favorite mirror in the next 24/48 hours. If you currently use these modules or the above technique to make your mod_perl code work in both an 1.x and 2.x environment you are encouraged to make these changes as well.

2006-01-24T08:00:00 2018-04-18T16:01:09.317982 2006 perl