--- loncom/auth/lonacc.pm 2016/08/16 20:17:49 1.164 +++ loncom/auth/lonacc.pm 2016/12/05 00:51:43 1.165 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.164 2016/08/16 20:17:49 raeburn Exp $ +# $Id: lonacc.pm,v 1.165 2016/12/05 00:51:43 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -339,10 +339,24 @@ sub sso_login { } unless ($hosthere) { ($is_balancer,$otherserver) = - &Apache::lonnet::check_loadbalancing($user,$domain); + &Apache::lonnet::check_loadbalancing($user,$domain,'login'); + if ($is_balancer) { + if ($otherserver eq '') { + my $lowest_load; + ($otherserver,undef,undef,undef,$lowest_load) = &Apache::lonnet::choose_server($domain); + if ($lowest_load > 100) { + $otherserver = &Apache::lonnet::spareserver($lowest_load,$lowest_load,1,$domain); + } + } + if ($otherserver ne '') { + my @hosts = &Apache::lonnet::current_machine_ids(); + if (grep(/^\Q$otherserver\E$/,@hosts)) { + $hosthere = $otherserver; + } + } + } } - - if ($is_balancer) { + if (($is_balancer) && (!$hosthere)) { # login but immediately go to switch server to find us a new # machine &Apache::lonauth::success($r,$user,$domain,$home,'noredirect'); @@ -384,6 +398,9 @@ sub sso_login { $info{'sso.reloginserver'} = $r->dir_config('lonSSOReloginServer'); } + if (($is_balancer) && ($hosthere)) { + $info{'noloadbalance'} = $hosthere; + } my $token = &Apache::lonnet::tmpput(\%info, $r->dir_config('lonHostID'));