You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2019/08/19 12:29:37 UTC

svn commit: r1865449 - in /perl/modperl/trunk: ModPerl-Registry/lib/ModPerl/RegistryLoader.pm lib/Apache2/compat.pm t/lib/TestAPRlib/finfo.pm t/response/TestAPI/request_rec.pm t/response/TestAPR/finfo.pm xs/Apache2/RequestIO/Apache2__RequestIO.h

Author: stevehay
Date: Mon Aug 19 12:29:37 2019
New Revision: 1865449

URL: http://svn.apache.org/viewvc?rev=1865449&view=rev
Log:
Avoid use of FINFO_NORM where possible; if not possible then switch off the FINFO_PROT bits on Windows

Some Windows set-ups have problems using apr_stat()'s FINFO_NORM mode: see https://bz.apache.org/bugzilla/show_bug.cgi?id=51560 and the dev@apr.apache.org thread cited in Comment 4 on that bug.

The problem revolves around the information requested by the APR_FINFO_GPROT and APR_FINFO_WPROT bits. We don't appear to need that information in what we're doing, so the simplest workaround is to turn off those bits (and the APR_FINFO_UPROT bit) in what we're requesting -- but only on WIN32, to minimize regression risk.

In some places we clearly only need a tiny subset of what FINFO_NORM gives us anyway, and switching to FINFO_MIN etc instead is even easier (and hopefully risk-free).

Modified:
    perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm
    perl/modperl/trunk/lib/Apache2/compat.pm
    perl/modperl/trunk/t/lib/TestAPRlib/finfo.pm
    perl/modperl/trunk/t/response/TestAPI/request_rec.pm
    perl/modperl/trunk/t/response/TestAPR/finfo.pm
    perl/modperl/trunk/xs/Apache2/RequestIO/Apache2__RequestIO.h

Modified: perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm (original)
+++ perl/modperl/trunk/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm Mon Aug 19 12:29:37 2019
@@ -24,7 +24,7 @@ use Apache2::ServerUtil ();
 use Apache2::Log ();
 use APR::Pool ();
 use APR::Finfo ();
-use APR::Const -compile=>qw(FINFO_NORM);
+use APR::Const -compile=>qw(FINFO_MIN);
 
 use Carp;
 use File::Spec ();
@@ -116,7 +116,7 @@ sub filename { shift->{filename} }
 sub status   { Apache2::Const::HTTP_OK }
 sub pool     { shift->{pool}||=APR::Pool->new() }
 sub finfo    { $_[0]->{finfo}||=APR::Finfo::stat($_[0]->{filename},
-                                                 APR::Const::FINFO_NORM,
+                                                 APR::Const::FINFO_MIN,
                                                  $_[0]->pool); }
 sub uri      { shift->{uri} }
 sub path_info {}

Modified: perl/modperl/trunk/lib/Apache2/compat.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/lib/Apache2/compat.pm?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/lib/Apache2/compat.pm (original)
+++ perl/modperl/trunk/lib/Apache2/compat.pm Mon Aug 19 12:29:37 2019
@@ -62,7 +62,7 @@ use mod_perl2 ();
 use Symbol ();
 use File::Spec ();
 
-use APR::Const -compile => qw(FINFO_NORM);
+use APR::Const -compile => qw(FINFO_NORM FINFO_PROT);
 
 BEGIN {
     $INC{'Apache.pm'} = __FILE__;
@@ -92,7 +92,11 @@ my %overridable_mp2_api = (
         if (defined $newfile) {
             $old_filename = $r->$orig_sub($newfile);
             die "'$newfile' doesn't exist" unless -e $newfile;
-            $r->finfo(APR::Finfo::stat($newfile, APR::Const::FINFO_NORM, $r->pool));
+            my $wanted = APR::Const::FINFO_NORM;
+            if (WIN32) {
+                $wanted &= ~APR::Const::FINFO_PROT;
+            }
+            $r->finfo(APR::Finfo::stat($newfile, $wanted, $r->pool));
         }
         else {
             $old_filename = $r->$orig_sub();

Modified: perl/modperl/trunk/t/lib/TestAPRlib/finfo.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/lib/TestAPRlib/finfo.pm?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/t/lib/TestAPRlib/finfo.pm (original)
+++ perl/modperl/trunk/t/lib/TestAPRlib/finfo.pm Mon Aug 19 12:29:37 2019
@@ -21,7 +21,7 @@ use constant OSX   => Apache::TestConfig
 use constant APACHE_2_0_49_PLUS => have_min_apache_version('2.0.49');
 use constant APACHE_2_2_PLUS    => have_min_apache_version('2.2.0');
 
-use APR::Const -compile => qw(SUCCESS FINFO_NORM FILETYPE_REG
+use APR::Const -compile => qw(SUCCESS FINFO_NORM FINFO_PROT FILETYPE_REG
                               FPROT_WREAD FPROT_WWRITE
                               FPROT_WEXECUTE);
 
@@ -39,7 +39,11 @@ sub test {
 
     my $pool = APR::Pool->new();
     # populate the finfo struct first
-    my $finfo = APR::Finfo::stat($file, APR::Const::FINFO_NORM, $pool);
+    my $wanted = APR::Const::FINFO_NORM;
+    if (WIN32) {
+        $wanted &= ~APR::Const::FINFO_PROT;
+    }
+    my $finfo = APR::Finfo::stat($file, $wanted, $pool);
 
     ok $finfo->isa('APR::Finfo');
 
@@ -70,7 +74,7 @@ sub test {
 
     # stat() on out-of-scope pools
     {
-        my $finfo = APR::Finfo::stat($file, APR::Const::FINFO_NORM, APR::Pool->new);
+        my $finfo = APR::Finfo::stat($file, $wanted, APR::Pool->new);
 
         # try to overwrite the temp pool data
         require APR::Table;

Modified: perl/modperl/trunk/t/response/TestAPI/request_rec.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestAPI/request_rec.pm?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestAPI/request_rec.pm (original)
+++ perl/modperl/trunk/t/response/TestAPI/request_rec.pm Mon Aug 19 12:29:37 2019
@@ -15,7 +15,7 @@ use APR::Finfo ();
 use APR::Pool ();
 
 use Apache2::Const -compile => qw(OK M_GET M_PUT);
-use APR::Const    -compile => qw(FINFO_NORM);
+use APR::Const    -compile => qw(FINFO_NAME);
 
 #this test module is only for testing fields in the request_rec
 #listed in apache_structures.map
@@ -165,7 +165,7 @@ sub handler {
 
     # finfo
     {
-        my $finfo = APR::Finfo::stat(__FILE__, APR::Const::FINFO_NORM, $r->pool);
+        my $finfo = APR::Finfo::stat(__FILE__, APR::Const::FINFO_NAME, $r->pool);
         $r->finfo($finfo);
         # just one field test, all accessors are fully tested in
         # TestAPR::finfo

Modified: perl/modperl/trunk/t/response/TestAPR/finfo.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestAPR/finfo.pm?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestAPR/finfo.pm (original)
+++ perl/modperl/trunk/t/response/TestAPR/finfo.pm Mon Aug 19 12:29:37 2019
@@ -15,7 +15,6 @@ use TestAPRlib::finfo;
 use APR::Finfo ();
 
 use Apache2::Const -compile => 'OK';
-use APR::Const    -compile => qw(FINFO_NORM);
 
 sub handler {
     my $r = shift;

Modified: perl/modperl/trunk/xs/Apache2/RequestIO/Apache2__RequestIO.h
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/xs/Apache2/RequestIO/Apache2__RequestIO.h?rev=1865449&r1=1865448&r2=1865449&view=diff
==============================================================================
--- perl/modperl/trunk/xs/Apache2/RequestIO/Apache2__RequestIO.h (original)
+++ perl/modperl/trunk/xs/Apache2/RequestIO/Apache2__RequestIO.h Mon Aug 19 12:29:37 2019
@@ -359,7 +359,7 @@ apr_status_t mpxs_Apache2__RequestRec_se
 
     if (!len) {
         apr_finfo_t finfo;
-        apr_file_info_get(&finfo, APR_FINFO_NORM, fp);
+        apr_file_info_get(&finfo, APR_FINFO_SIZE, fp);
         len = finfo.size;
         if (offset) {
             len -= offset;