X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCluster.pm;h=98ceafa9c0d55170c1b220b9fcceda9b87842965;hb=3d29b1a4d4aab997da2deff10470068601744530;hp=4e94f4afb6ecb9c8f8b991c7bcef7639a84c6ff1;hpb=2546ef0cfaaca39e65985e414258071a636979af;p=spider.git diff --git a/perl/DXCluster.pm b/perl/DXCluster.pm index 4e94f4af..98ceafa9 100644 --- a/perl/DXCluster.pm +++ b/perl/DXCluster.pm @@ -16,8 +16,8 @@ package DXCluster; use Exporter; @ISA = qw(Exporter); -use Carp; use DXDebug; +use Carp; use strict; use vars qw(%cluster %valid); @@ -137,6 +137,7 @@ sub new $node->{list}->{$call} = $self; # add this user to the list on this node $users++; dbg('cluster', "allocating user $call to $node->{call} in cluster\n"); + $node->update_users; return $self; } @@ -145,10 +146,11 @@ sub del my $self = shift; my $call = $self->{call}; my $node = $self->{mynode}; - + delete $node->{list}->{$call}; delete $DXCluster::cluster{$call}; # remove me from the cluster table dbg('cluster', "deleting user $call from $node->{call} in cluster\n"); + $node->update_users; $users-- if $users > 0; } @@ -206,6 +208,7 @@ sub del foreach $ref (values %{$self->{list}}) { $ref->del(); # this also takes them out of this list } + delete $DXCluster::cluster{$call}; # remove me from the cluster table dbg('cluster', "deleting node $call from cluster\n"); $nodes-- if $nodes > 0; } @@ -213,10 +216,11 @@ sub del sub update_users { my $self = shift; - if (%{$self->{list}}) { - $self->{users} = scalar %{$self->{list}}; + my $count = shift; + if ((keys %{$self->{list}})) { + $self->{users} = (keys %{$self->{list}}); } else { - $self->{users} = shift; + $self->{users} = $count; } }