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

raeburn raeburn at source.lon-capa.org
Wed May 6 09:34:22 EDT 2020


raeburn		Wed May  6 13:34:22 2020 EDT

  Modified files:              
    /loncom	loncron 
  Log:
  - symlink removed when session file to which it links is stale.
  
  
Index: loncom/loncron
diff -u loncom/loncron:1.121 loncom/loncron:1.122
--- loncom/loncron:1.121	Sat Jan 11 22:37:19 2020
+++ loncom/loncron	Wed May  6 13:34:22 2020
@@ -2,7 +2,7 @@
 
 # Housekeeping program, started by cron, loncontrol and loncron.pl
 #
-# $Id: loncron,v 1.121 2020/01/11 22:37:19 raeburn Exp $
+# $Id: loncron,v 1.122 2020/05/06 13:34:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -495,19 +495,38 @@
     my $cleaned=0;
     my $active=0;
     while (my $fname=<$perlvar{'lonIDsDir'}/*>) {
-	my ($dev,$ino,$mode,$nlink,
-	    $uid,$gid,$rdev,$size,
-	    $atime,$mtime,$ctime,
-	    $blksize,$blocks)=stat($fname);
-	my $now=time;
-	my $since=$now-$mtime;
-	if ($since>$perlvar{'lonExpire'}) {
-	    $cleaned++;
-	    &log($fh,"Unlinking $fname<br />");
-	    unlink("$fname");
-	} else {
-	    $active++;
-	}
+        my $now=time;
+        if (-l $fname) {
+            my $linkfname = readlink($fname);
+            if (-f $linkfname) {
+                if ($linkfname =~ m{^$perlvar{'lonIDsDir'}/[^/]+\.id$}) {
+                    my @data = stat($linkfname);
+                    my $mtime = $data[9];
+                    my $since=$now-$mtime;
+                    if ($since>$perlvar{'lonExpire'}) {
+                        if (unlink($linkfname)) {
+                            $cleaned++;
+                            &log($fh,"Unlinking $linkfname<br />");
+                            unlink($fname);
+                        }
+                    }
+                }
+            } else {
+               unlink($fname);
+            }
+        } elsif (-f $fname) {
+            my @data = stat($fname);
+            my $mtime = $data[9];
+            my $since=$now-$mtime;
+            if ($since>$perlvar{'lonExpire'}) {
+                if (unlink($fname)) {
+                    $cleaned++;
+                    &log($fh,"Unlinking $fname<br />");
+                }
+            } else {
+                $active++;
+            }
+        }
     }
     &log($fh,"<p>Cleaned up ".$cleaned." stale session token(s).</p>");
     &log($fh,"<h3>$active open session(s)</h3>");




More information about the LON-CAPA-cvs mailing list