--- loncom/lonnet/perl/lonnet.pm 2007/01/25 21:10:51 1.824.2.1 +++ loncom/lonnet/perl/lonnet.pm 2007/01/18 15:58:29 1.826 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.824.2.1 2007/01/25 21:10:51 albertel Exp $ +# $Id: lonnet.pm,v 1.826 2007/01/18 15:58:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -367,26 +367,6 @@ sub transfer_profile_to_env { } } -sub timed_flock { - my ($file,$lock_type) = @_; - my $failed=0; - eval { - local $SIG{__DIE__}='DEFAULT'; - local $SIG{ALRM}=sub { - $failed=1; - die("failed lock"); - }; - alarm(13); - flock($file,$lock_type); - alarm(0); - }; - if ($failed) { - return undef; - } else { - return 1; - } -} - # ---------------------------------------------------------- Append Environment sub appenv { @@ -401,11 +381,8 @@ sub appenv { $env{$key}=$newenv{$key}; } } - open(my $env_file,$env{'user.environment'}); - if (&timed_flock($env_file,LOCK_EX) - && - tie(my %disk_env,'GDBM_File',$env{'user.environment'}, - (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { + if (tie(my %disk_env,'GDBM_File',$env{'user.environment'},&GDBM_WRITER(), + 0640)) { while (my ($key,$value) = each(%newenv)) { $disk_env{$key} = $value; } @@ -422,11 +399,8 @@ sub delenv { "Attempt to delete from environment ".$delthis); return 'error'; } - open(my $env_file,$env{'user.environment'}); - if (&timed_flock($env_file,LOCK_EX) - && - tie(my %disk_env,'GDBM_File',$env{'user.environment'}, - (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { + if (tie(my %disk_env,'GDBM_File',$env{'user.environment'},&GDBM_WRITER(), + 0640)) { foreach my $key (keys(%disk_env)) { if ($key=~/^$delthis/) { delete($env{$key}); @@ -7169,6 +7143,10 @@ sub repcopy_userfile { if ($lwpresp ne 'ok') { my $ua=new LWP::UserAgent; my $request=new HTTP::Request('GET',&tokenwrapper($uri)); + # FIXME, right reads everything into memory then writes it out + # doing something like + # my $response=$ua->request($request,$file); + # would make this write directly to disk my $response=$ua->request($request); if ($response->is_success()) { $info=$response->content; @@ -7523,7 +7501,7 @@ sub get_iphost { if (!exists($name_to_ip{$name})) { $ip = gethostbyname($name); if (!$ip || length($ip) ne 4) { - &logthis("Skipping host $id name $name no IP found\n"); + &logthis("Skipping host $id name $name no IP found"); next; } $ip=inet_ntoa($ip);