Add set/maxconnect command
[spider.git] / perl / cluster.pl
index 46f4818325af00ef5945e48ac2027e58dbef3877..0bf306599d30ee09f7650f4f0ae04ca85c4170b4 100755 (executable)
@@ -187,12 +187,15 @@ sub new_channel
 
        # (fairly) politely disconnect people that are connected to too many other places at once
        my $r = Route::get($call);
-       if ($r) {
+       if ($r && $user) {
                my @n = $r->parents;
-               my $v = $r->isa('Route::Node') ? $maxconnect_node : $maxconnect_user;
+               my $m = $r->isa('Route::Node') ? $maxconnect_node : $maxconnect_user;
+               my $c = $user->maxconnect;
+               my $v;
+               $v = defined $c ? $c : $m;
                if ($v && @n >= $v) {
                        my $nodes = join ',', @n;
-                       LogDbg('DXCommand', "$call has too many connections ($v) at $nodes, disconnected");
+                       LogDbg('DXCommand', "$call has too many connections ($v) at $nodes - disconnected");
                        already_conn($conn, $call, DXM::msg($lang, 'contomany', $call, $v, $nodes));
                        return;
                }