You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Frank Wiles <fr...@wiles.org> on 2005/07/03 21:14:39 UTC

Re: Robust way to check for version number [FEATURE REQUEST / HOW-TO]

On Wed, 29 Jun 2005 16:36:46 +0200
Dominique Quatravaux <do...@idealx.com> wrote:

> $mod_perl2::VERSION skips these drawbacks (it can only be altered from
> Perl and is not inherited) but it is currently not trustworthy either:
> 
>  $ perl -Mmod_perl2 -e 'print $mod_perl2::VERSION'
>  2.000001

  Sorry for the late reply on this, managed to get way behind on E-mail
  over the last week. Why isn't that a reliable method? 

> BTW this problem triggers a bug in e.g. Apache::DB when several
> installations of mod_perl (1.26 and 2.000001 in my case) cohabit on
> the same system (I'm sending a separate bug report to Frank Wiles).
> 
> The only reliable way of checking for mod_perl is by probing for an
> "unusual" feature of the Perl runtime, say an XS sub that the core of
> mod_perl provides directly. Here is the crock I'm currently using to
> that effect:
> 
> sub mod_perl_version {
>     my @discriminating_symbols =
>         (2 => "Apache2::XSLoader::BOOTSTRAP",
>          1.99 => "Apache::XSLoader::BOOTSTRAP",
>          1 => "Apache::exit");
> 
>     use B;
>     while(my ($version, $discrimsymbol) =
>           splice(@discriminating_symbols, 0, 2)) {
>         no strict "refs";
>         next if (! exists &{$discrimsymbol});
>         my $bref = B::svref_2object(\&{$discrimsymbol});
>         next if ( (! defined $bref) || (! $bref->XSUB()) );
>         return $version;
>     }
>     return undef;
> }

  Well I'm not entirely against doing this, but I wouldn't want to
  support older 1.99 releases of the code.  This would just help
  encourage people to use old unsupported and/or non-standard MP2 APIs.

 ---------------------------------
   Frank Wiles <fr...@wiles.org>
   http://www.wiles.org
 ---------------------------------


Re: Robust way to check for version number [FEATURE REQUEST / HOW-TO]

Posted by Dominique Quatravaux <do...@idealx.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Frank Wiles wrote:


>>
>> $ perl -Mmod_perl2 -e 'print $mod_perl2::VERSION' 2.000001
>
>
> Why isn't that a reliable method?

It's an OK method for a useless item of knowledge (namely the version
of mod_perl2.pm currently loaded), but not for finding out the
mod_perl version we are running under (in the CLI example we are
obviously not running under mod_perl at all).

>>
>> sub mod_perl_version { my @discriminating_symbols = (2 =>
>> "Apache2::XSLoader::BOOTSTRAP", 1.99 =>
>> "Apache::XSLoader::BOOTSTRAP", 1 => "Apache::exit");
>>
>> use B; while(my ($version, $discrimsymbol) =
>> splice(@discriminating_symbols, 0, 2)) { no strict "refs"; next
>> if (! exists &{$discrimsymbol}); my $bref =
>> B::svref_2object(\&{$discrimsymbol}); next if ( (! defined $bref)
>> || (! $bref->XSUB()) ); return $version; } return undef; }
>
>
> Well I'm not entirely against doing this, but I wouldn't want to
> support older 1.99 releases of the code. This would just help
> encourage people to use old unsupported and/or non-standard MP2
> APIs.

Oh. Then just remove the relevant line in @discriminating_symbols :-)

Actually the best thing to do would be to provide a
mod_perl::running_version() XS sub that gives an authoritative answer.
I posted my above ad-hoc crock as a temporary workaround to be used by
other MP2-related package maintainers out there (esp. Apache::DB -
Pretty please? :), not as a patch suggestion for mod_perl itself.

> Sorry for the late reply on this, managed to get way behind on
> E-mail over the last week.
>
IMHO you don't need to apologize for this to anybody (benevolent spare
time etc.). Thanks for your work!


- --
Dominique QUATRAVAUX                           Ingénieur senior
01 44 42 00 08                                 IDEALX

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCyPANMJAKAU3mjcsRAoNMAJ0axRZ25MQHtia4PoMD4/R2yszbSQCePTqS
TNVCVKbUdx2eI8co4dgkHCE=
=xcw0
-----END PGP SIGNATURE-----