[LON-CAPA-cvs] cvs: loncom(version_2_5_X) /lonnet/perl lonnet.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 01 Oct 2007 21:54:08 -0000


albertel		Mon Oct  1 17:54:08 2007 EDT

  Modified files:              (Branch: version_2_5_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - backport 1.915
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.910.2.2 loncom/lonnet/perl/lonnet.pm:1.910.2.3
--- loncom/lonnet/perl/lonnet.pm:1.910.2.2	Sat Sep 29 00:06:34 2007
+++ loncom/lonnet/perl/lonnet.pm	Mon Oct  1 17:54:06 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.910.2.2 2007/09/29 04:06:34 albertel Exp $
+# $Id: lonnet.pm,v 1.910.2.3 2007/10/01 21:54:06 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -320,7 +320,10 @@
     my ($lonidsdir,$handle)=@_;
     my @profile;
     {
-	open(my $idf,"$lonidsdir/$handle.id");
+	open(my $idf,'+<',"$lonidsdir/$handle.id");
+	if (!$idf) {
+	    return 0;
+	}
 	flock($idf,LOCK_SH);
 	@profile=<$idf>;
 	close($idf);
@@ -359,7 +362,10 @@
 
     my $convert;
     {
-    	open(my $idf,"$lonidsdir/$handle.id");
+    	open(my $idf,'+<',"$lonidsdir/$handle.id");
+	if (!$idf) {
+	    return;
+	}
 	flock($idf,LOCK_SH);
 	if (tie(my %disk_env,'GDBM_File',"$lonidsdir/$handle.id",
 		&GDBM_READER(),0640)) {
@@ -425,8 +431,9 @@
             $env{$key}=$newenv{$key};
         }
     }
-    open(my $env_file,$env{'user.environment'});
-    if (&timed_flock($env_file,LOCK_EX)
+    open(my $env_file,'+<',$env{'user.environment'});
+    if ($env_file
+	&& &timed_flock($env_file,LOCK_EX)
 	&&
 	tie(my %disk_env,'GDBM_File',$env{'user.environment'},
 	    (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) {
@@ -446,16 +453,17 @@
                 "Attempt to delete from environment ".$delthis);
         return 'error';
     }
-    open(my $env_file,$env{'user.environment'});
-    if (&timed_flock($env_file,LOCK_EX)
+    open(my $env_file,'+<',$env{'user.environment'});
+    if ($env_file
+	&& &timed_flock($env_file,LOCK_EX)
 	&&
 	tie(my %disk_env,'GDBM_File',$env{'user.environment'},
 	    (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) {
 	foreach my $key (keys(%disk_env)) {
 	    if ($key=~/^$delthis/) { 
-                delete($env{$key});
-                delete($disk_env{$key});
-            }
+		delete($env{$key});
+		delete($disk_env{$key});
+	    }
 	}
 	untie(%disk_env);
     }