From 85af504a4bc9ce2e158dfe0cb9dc3750d1cf98f5 Mon Sep 17 00:00:00 2001 From: fukachan Date: Tue, 18 Mar 2003 14:14:50 +0000 Subject: modify chaddr algorithm: "del() and add()" -> "add() and del()". # XXX WHICH STEP IS IT BETTER TO UPDATE LIST ? # [I] 1. remove the old address only if $new_address not included. # 2. add the newadderss # [II] 1. add the newadderss # 2. remove the old address only if $new_address not included. # # Plan [II] is better for authentication without reader lock. # Consider the case the process executing chaddr is preempted, and # another distributing process starts to run. --- fml/lib/FML/Command/UserControl.pm | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'fml/lib/FML/Command/UserControl.pm') diff --git a/fml/lib/FML/Command/UserControl.pm b/fml/lib/FML/Command/UserControl.pm index fc95b861..b405de79 100644 --- a/fml/lib/FML/Command/UserControl.pm +++ b/fml/lib/FML/Command/UserControl.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: UserControl.pm,v 1.28 2003/03/17 13:27:15 fukachan Exp $ +# $FML: UserControl.pm,v 1.29 2003/03/18 10:42:41 fukachan Exp $ # package FML::Command::UserControl; @@ -277,36 +277,45 @@ sub _try_chaddr_in_map # 3. both conditions are o.k., here we go! # XXX-TODO: this condition is correct ? # XXX-TODO: we should remove old one when both old and new ones exist. + # XXX WHICH STEP IS IT BETTER TO UPDATE LIST ? + # [I] 1. remove the old address only if $new_address not included. + # 2. add the newadderss + # [II] 1. add the newadderss + # 2. remove the old address only if $new_address not included. + # + # Plan [II] is better for authentication without reader lock. + # Consider the case the process executing chaddr is preempted, and + # another distributing process starts to run. + # if ($is_old_address_ok && $is_new_address_ok) { - # remove the old address only if $new_address not included. { my $obj = new IO::Adapter $map, $config; - $obj->touch(); - $obj->open(); - $obj->delete( $old_address_in_map ); + $obj->add( $new_address ); unless ($obj->error()) { - Log("delete $old_address from map=$map"); + Log("add $new_address to map=$map"); } else { - LogError("fail to delete $old_address to map=$map"); + LogError("fail to add $new_address to map=$map"); } - $obj->close(); + $obj->close(); } # restart map to add the new address. # XXX we need to restart or rewrind map. { my $obj = new IO::Adapter $map, $config; + $obj->touch(); + $obj->open(); - $obj->add( $new_address ); + $obj->delete( $old_address_in_map ); unless ($obj->error()) { - Log("add $new_address to map=$map"); + Log("delete $old_address from map=$map"); } else { - LogError("fail to add $new_address to map=$map"); + LogError("fail to delete $old_address to map=$map"); } - $obj->close(); + $obj->close(); } } } -- cgit v1.2.1