[LON-CAPA-cvs] cvs: loncom / loncron

www lon-capa-cvs@mail.lon-capa.org
Mon, 27 May 2002 19:21:59 -0000


www		Mon May 27 15:21:59 2002 EDT

  Modified files:              
    /loncom	loncron 
  Log:
  Cleans up CHECKOUTTOKENS only after 100 times normal expiration. Bug #240.
  
  
Index: loncom/loncron
diff -u loncom/loncron:1.28 loncom/loncron:1.29
--- loncom/loncron:1.28	Wed May 22 17:41:34 2002
+++ loncom/loncron	Mon May 27 15:21:59 2002
@@ -239,6 +239,7 @@
 # --------------------------------------------------------------- clean out tmp
 print $fh '<hr><a name="tmp"><h2>Temporary Files</h2>';
 $cleaned=0;
+$old=0;
 while ($fname=<$perlvar{'lonDaemons'}/tmp/*>) {
                           my ($dev,$ino,$mode,$nlink,
                               $uid,$gid,$rdev,$size,
@@ -247,12 +248,24 @@
                           $now=time;
                           $since=$now-$mtime;
                           if ($since>$perlvar{'lonExpire'}) {
-                              $cleaned++;
-                              unlink("$fname");
+                              $line='';
+                              if (open(PROBE,$fname)) {
+				  $line=<PROBE>;
+                                  close(PROBE);
+			      }
+			      unless ($line=~/^CHECKOUTTOKEN\&/) {
+                                 $cleaned++;
+                                 unlink("$fname");
+			      } else {
+				  if ($since>100*$perlvar{'lonExpire'}) {
+                                     $cleaned++;
+                                     unlink("$fname");
+				 } else { $old++; }
+                              }
                           }
     
 }
-print $fh "Cleaned up ".$cleaned." files.";
+print $fh "Cleaned up ".$cleaned." files (".$old." old checkout tokens).";
 
 # ------------------------------------------------------------ clean out lonIDs
 print $fh '<hr><a name="tokens"><h2>Session Tokens</h2>';