perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@covalent.net>
Subject Re: cvs commit: modperl ToDo
Date Wed, 13 Sep 2000 07:51:50 GMT
On 2 Sep 2000, Andreas J. Koenig wrote:

> >>>>> On Fri, 1 Sep 2000 15:46:46 -0700 (PDT), Doug MacEachern <dougm@covalent.net>
said:
> 
>   > perhaps, i've cc'd andreas who originally chose -M, i have the feeling we
>   > discussed the reasons ages ago.  andreas, do you see any reason not to use
>   > (stat _)[9] instead of -M _ ?
>  
> I'm falling aslep while I write, so please forgive me if I say
> something stupid...

and me, falling aslep too :)
 
> You cannot change between -M _ and (stat _)[9] without inverting the
> comparison function too. If you watch a file's mtime within a perl
> program, -M _ will get smaller (and below zero) while (stat _)[9] will
> get bigger. So if you check for <= now, this would become >=
> 
> Otherwise I see no strong reason to use one or the other. I kind of
> like -M here because it's shorter to read/write and it's a smaller
> number and easier to compare visually. But, of course, it's risky if
> somebody plays with $^T, then they can break -M by action at a
> distance while they cannot break the stat thing.

thanks andreas!  ok, so i guess this is the right patch?

Index: lib/Apache/PerlRun.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/PerlRun.pm,v
retrieving revision 1.29
diff -u -r1.29 PerlRun.pm
--- lib/Apache/PerlRun.pm	2000/06/01 21:07:56	1.29
+++ lib/Apache/PerlRun.pm	2000/09/13 07:49:07
@@ -57,7 +57,7 @@
 	    return FORBIDDEN;
 	}
 
-	$pr->{'mtime'} = -M _;
+	$pr->{'mtime'} = (stat _)[9];
 	return wantarray ? (OK, $pr->{'mtime'}) : OK;
     }
     return NOT_FOUND;
@@ -101,7 +101,7 @@
     $mtime   ||= $pr->{'mtime'};
     !($pr->cached
     &&
-      $Apache::Registry->{$package}{'mtime'} <= $mtime);
+      $Apache::Registry->{$package}{'mtime'} >= $mtime);
 }
 
 sub set_mtime {
Index: lib/Apache/Registry.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/Registry.pm,v
retrieving revision 1.32
diff -u -r1.32 Registry.pm
--- lib/Apache/Registry.pm	2000/08/02 15:53:15	1.32
+++ lib/Apache/Registry.pm	2000/09/13 07:49:07
@@ -55,7 +55,7 @@
 	    return FORBIDDEN;
 	}
 
-	my $mtime = -M _;
+	my $mtime = (stat _)[9];
 
 	my $uri = $r->uri;
 	# turn into a package name
@@ -94,7 +94,7 @@
 	if (
 	    exists $Apache::Registry->{$package}{'mtime'}
 	    &&
-	    $Apache::Registry->{$package}{'mtime'} <= $mtime
+	    $Apache::Registry->{$package}{'mtime'} >= $mtime
 	   ){
 	    # we have compiled this subroutine already, nothing left to do
  	} else {


Mime
View raw message