diff options
| author | fukachan <fukachan> | 2003-03-18 10:42:40 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-03-18 10:42:40 +0000 |
| commit | 3be0d18d4f3196fad45761c405bbfc2a3b71a82e (patch) | |
| tree | 659aad4273b9d4d502c4667c6a55d487867139f2 /fml/lib/FML/Command/UserControl.pm | |
| parent | d381df5a5824e204f61d7279ee6b798aec81c200 (diff) | |
| download | fml8-3be0d18d4f3196fad45761c405bbfc2a3b71a82e.tar.gz fml8-3be0d18d4f3196fad45761c405bbfc2a3b71a82e.tar.bz2 fml8-3be0d18d4f3196fad45761c405bbfc2a3b71a82e.zip | |
remove giant lock and use fine granuality locks now.
Diffstat (limited to 'fml/lib/FML/Command/UserControl.pm')
| -rw-r--r-- | fml/lib/FML/Command/UserControl.pm | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/fml/lib/FML/Command/UserControl.pm b/fml/lib/FML/Command/UserControl.pm index 85b94eee..fc95b861 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.27 2003/02/15 02:25:40 fukachan Exp $ +# $FML: UserControl.pm,v 1.28 2003/03/17 13:27:15 fukachan Exp $ # package FML::Command::UserControl; @@ -17,6 +17,11 @@ use FML::Restriction::Base; use FML::Log qw(Log LogWarn LogError); use IO::Adapter; + +# XXX_LOCK_CHANNEL: recipient_map_modify +my $lock_channel = "recipient_map_modify"; + + # # XXX-TODO: we use this module to add/del user anywhere. # @@ -62,6 +67,7 @@ sub useradd my $address = $uc_args->{ address }; my $maplist = $uc_args->{ maplist }; my $trycount = 0; + my $reason = ''; # XXX check if $address is safe (persistent ?). my $safe = new FML::Restriction::Base; @@ -74,6 +80,10 @@ sub useradd $msg_args->{ _arg_address } = $address; my $ml_home_dir = $config->{ ml_home_dir }; + + $curproc->lock($lock_channel); + + MAP: for my $map (@$maplist) { my $_map = $map; $_map =~ s@$ml_home_dir@\$ml_home_dir@; @@ -102,15 +112,21 @@ sub useradd $curproc->reply_message_nl('command.add_fail', "failed to add $address", $msg_args); - croak("fail to add $address to map=$_map"); + $reason = "fail to add $address to map=$_map"; + last MAP; } } else { - croak( "$address is already member (map=$_map)" ); - return undef; + $reason = "$address is already member (map=$_map)"; + last MAP; } } + $curproc->unlock($lock_channel); + if ($reason) { + croak($reason); + } + unless ($trycount) { LogError("no trail to add $address"); } @@ -129,6 +145,7 @@ sub userdel my $address = $uc_args->{ address }; my $maplist = $uc_args->{ maplist }; my $trycount = 0; + my $reason = ''; # XXX check if $address is safe (persistent ?). my $safe = new FML::Restriction::Base; @@ -141,6 +158,10 @@ sub userdel $msg_args->{ _arg_address } = $address; my $ml_home_dir = $config->{ ml_home_dir }; + + $curproc->lock($lock_channel); + + MAP: for my $map (@$maplist) { my $_map = $map; $_map =~ s@$ml_home_dir@\$ml_home_dir@; @@ -172,7 +193,8 @@ sub userdel $curproc->reply_message_nl('command.del_fail', "failed to remove $address", $msg_args); - croak("fail to remove $address from map=$_map"); + $reason = "fail to remove $address from map=$_map"; + last MAP; } } else { @@ -180,6 +202,11 @@ sub userdel } } + $curproc->unlock($lock_channel); + if ($reason) { + croak($reason); + } + unless ($trycount) { LogError("no trail to remove $address"); } @@ -200,11 +227,15 @@ sub user_chaddr # save excursion: exatct match as could as possible. $cred->set_compare_level( 100 ); + $curproc->lock($lock_channel); + for my $map (@$maplist) { $self->_try_chaddr_in_map($curproc, $command_args, $uc_args, $cred, $map); } + $curproc->unlock($lock_channel); + # reset enironment. $cred->set_compare_level( $level ); } @@ -258,7 +289,7 @@ sub _try_chaddr_in_map Log("delete $old_address from map=$map"); } else { - croak("fail to delete $old_address to map=$map"); + LogError("fail to delete $old_address to map=$map"); } $obj->close(); } @@ -273,7 +304,7 @@ sub _try_chaddr_in_map Log("add $new_address to map=$map"); } else { - croak("fail to add $new_address to map=$map"); + LogError("fail to add $new_address to map=$map"); } $obj->close(); } @@ -294,6 +325,8 @@ sub userlist my $wh = $uc_args->{ wh }; my $style = $curproc->get_print_style(); + $curproc->lock($lock_channel); + for my $map (@$maplist) { my $obj = new IO::Adapter $map, $config; @@ -316,6 +349,8 @@ sub userlist LogWarn("canot open $map"); } } + + $curproc->unlock($lock_channel); } @@ -329,6 +364,8 @@ sub get_user_list my $config = $curproc->config(); my $r = []; + $curproc->lock($lock_channel); + for my $map (@$list) { my $io = new IO::Adapter $map, $config; my $key = ''; @@ -341,6 +378,8 @@ sub get_user_list } } + $curproc->unlock($lock_channel); + return $r; } |
