[LON-CAPA-cvs] cvs: loncom / lond
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 31 Jan 2006 15:37:42 -0000
albertel Tue Jan 31 10:37:42 2006 EDT
Modified files:
/loncom lond
Log:
- centralizing the usage of untie
Index: loncom/lond
diff -u loncom/lond:1.310 loncom/lond:1.311
--- loncom/lond:1.310 Mon Jan 30 23:40:12 2006
+++ loncom/lond Tue Jan 31 10:37:41 2006
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.310 2006/01/31 04:40:12 albertel Exp $
+# $Id: lond,v 1.311 2006/01/31 15:37:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.310 $'; #' stupid emacs
+my $VERSION='$Revision: 1.311 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -988,6 +988,10 @@
}
}
+sub untie_domain_hash {
+ my ($hashref) = @_;
+ untie(%$hashref);
+}
#
# Ties a user's resource file to a hash.
# If necessary, an appropriate history
@@ -1038,6 +1042,11 @@
}
+sub untie_user_hash {
+ my ($hashref) = @_;
+ my $result = untie(%$hashref);
+ return $result;
+}
# read_profile
#
# Returns a set of specific entries from a user's profile file.
@@ -1068,7 +1077,7 @@
$qresult.="$hashref->{$queries[$i]}&"; # Presumably failure gives empty string.
}
$qresult=~s/\&$//; # Remove trailing & from last lookup.
- if (untie %$hashref) {
+ if (&untie_user_hash($hashref)) {
return $qresult;
} else {
return "error: ".($!+0)." untie (GDBM) Failed";
@@ -2377,7 +2386,7 @@
my ($key,$value)=split(/=/,$pair);
$hashref->{$key}=$value;
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
&Reply( $client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) failed ".
@@ -2440,7 +2449,7 @@
$hashref->{$key}=$value;
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
&Reply( $client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) failed ".
@@ -2493,7 +2502,7 @@
}
}
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
&Reply( $client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) failed ".
@@ -2560,7 +2569,7 @@
$auth_type);
$hashref->{$key}=$value;
}
- if (untie($hashref)) {
+ if (&untie_user_hash($hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure( $client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -2611,7 +2620,7 @@
foreach my $key (@rolekeys) {
delete $hashref->{$key};
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash(%$hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure( $client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -2752,7 +2761,7 @@
foreach my $key (@keys) {
delete($hashref->{$key});
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash(%$hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -2794,7 +2803,7 @@
foreach my $key (keys %$hashref) {
$qresult.="$key&";
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash(%$hashref)) {
$qresult=~s/\&$//;
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -2855,7 +2864,7 @@
$data{$symb}->{$param}=$value;
$data{$symb}->{'v.'.$param}=$v;
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
while (my ($symb,$param_hash) = each(%data)) {
while(my ($param,$value) = each (%$param_hash)){
next if ($param =~ /^v\./); # Ignore versions...
@@ -2947,7 +2956,7 @@
}
}
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
chop($qresult);
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -3009,7 +3018,7 @@
$hashref->{"$version:$rid:timestamp"}=$now;
$allkeys.='timestamp';
$hashref->{"$version:keys:$rid"}=$allkeys;
- if (untie($hashref)) {
+ if (&untie_user_hash($hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -3076,7 +3085,7 @@
$qresult.="$scope:$key=".$hashref->{"$scope:$rid:$key"}."&";
}
}
- if (untie(%$hashref)) {
+ if (&untie_user_hash($hashref)) {
$qresult=~s/\&$//;
&Reply( $client, "$qresult\n", $userinput);
} else {
@@ -3309,7 +3318,7 @@
}
$hashref->{$key}=$courseinfo.':'.$now;
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
&Reply( $client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)
@@ -3425,7 +3434,7 @@
$qresult.=$key.'='.$descr.':'.$inst_code.':'.$owner.'&';
}
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
chop($qresult);
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -3474,7 +3483,7 @@
my ($key,$value)=split(/=/,$pair);
$hashref->{$key}=$value;
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -3523,7 +3532,7 @@
for (my $i=0;$i<=$#queries;$i++) {
$qresult.="$hashref->{$queries[$i]}&";
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
$qresult=~s/\&$//;
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -3567,7 +3576,7 @@
my ($key,$value)=split(/=/,$what);
$hashref->{$key}=$value;
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -3647,7 +3656,7 @@
$qresult.=$key.'='.$value.'&';
}
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
chop($qresult);
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -3694,7 +3703,7 @@
my ($key,$value)=split(/=/,$pair);
$hashref->{$key}=$value;
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
&Reply($client, "ok\n", $userinput);
} else {
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
@@ -3775,7 +3784,7 @@
$qresult.=$key.'='.$value.'&';
}
}
- if (untie(%$hashref)) {
+ if (&untie_domain_hash($hashref)) {
chop($qresult);
&Reply($client, "$qresult\n", $userinput);
} else {
@@ -5629,7 +5638,7 @@
&GDBM_READER());
if ($hashref) {
@entries=map { $_.':'.$hashref->{$_} } sort(keys(%$hashref));
- untie(%$hashref);
+ &untie_user_hash($hashref);
}
my @participants=();
my $cutoff=time-60;
@@ -5642,7 +5651,7 @@
push(@participants, 'active_participant:'.$user);
}
}
- untie(%$hashref);
+ &untie_user_hash($hashref);
}
return (@participants,@entries);
}
@@ -5679,7 +5688,7 @@
}
close(CHATLOG);
}
- untie(%$hashref);
+ &untie_user_hash($hashref);
}
}