--- loncom/lond 2006/05/11 17:53:22 1.325 +++ loncom/lond 2006/05/13 01:31:15 1.326 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.325 2006/05/11 17:53:22 albertel Exp $ +# $Id: lond,v 1.326 2006/05/13 01:31:15 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,7 +62,7 @@ my $status=''; my $lastlog=''; my $lond_max_wait_time = 13; -my $VERSION='$Revision: 1.325 $'; #' stupid emacs +my $VERSION='$Revision: 1.326 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -1051,6 +1051,41 @@ sub _do_hash_untie { sub _locking_hash_tie { my ($file_prefix,$namespace,$how,$loghead,$what) = @_; +# is this locked by an external program? + + if (-e "$file_prefix.db.lock") { + my $failed=0; + eval { + local $SIG{__DIE__}='DEFAULT'; + local $SIG{ALRM}=sub { + $failed=1; + die("failed lock"); + }; + alarm(2*$lond_max_wait_time); + while (-e "$file_prefix.db.lock") {} + alarm(0); + }; + if ($failed) { + $! = 100; # throwing error # 100 + return undef; + } + } + +# is this archived? + + if (-e "$file_prefix.db.gz") { +# lock immediately + open(TOUCH,">>$file_prefix.db.lock"); + close(TOUCH); + system("gunzip $file_prefix.db.gz"); + if (-e "$file_prefix.hist.gz") { + system("gunzip $file_prefix.hist.gz"); + } +# all set, unlock + unlink("$file_prefix.db.lock"); + } + + my ($lock); if ($how eq &GDBM_READER()) {