--- loncom/auth/lonacc.pm 2015/12/03 20:40:21 1.162 +++ loncom/auth/lonacc.pm 2017/05/08 22:47:01 1.167 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.162 2015/12/03 20:40:21 damieng Exp $ +# $Id: lonacc.pm,v 1.167 2017/05/08 22:47:01 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -109,7 +109,6 @@ sub cleanup { my ($r)=@_; if (! $r->is_initial_req()) { return DECLINED; } &Apache::lonnet::save_cache(); - &Apache::lontexconvert::jsMath_reset(); return OK; } @@ -340,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'); @@ -361,14 +374,7 @@ sub sso_login { } else { # need to login them in, so generate the need data that # migrate expects to do login - my $ip; - my $c = $r->connection; - eval { - $ip = $c->remote_ip(); - }; - if ($@) { - $ip = $c->client_ip(); - } + my $ip = $r->get_remote_host(); my %info=('ip' => $ip, 'domain' => $domain, 'username' => $user, @@ -392,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')); @@ -516,7 +525,8 @@ sub handler { } } elsif ($env{'request.course.id'} && (($requrl =~ m{^/adm/$match_domain/$match_username/aboutme$}) || - ($requrl =~ m{^/public/$cdom/$cnum/syllabus$}))) { + ($requrl eq "/public/$cdom/$cnum/syllabus") || + ($requrl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}))) { my $query = $r->args; if ($query) { foreach my $pair (split(/&/,$query)) { @@ -664,7 +674,8 @@ sub handler { ($requrl=~m|\.problem/smpedit$|) || ($requrl=~/^\/public\/.*\/syllabus$/) || ($requrl=~/^\/adm\/(viewclasslist|navmaps)$/) || - ($requrl=~/^\/adm\/.*\/aboutme\/portfolio(\?|$)/)) { + ($requrl=~/^\/adm\/.*\/aboutme\/portfolio(\?|$)/) || + ($requrl=~m{^/adm/$cdom/$cnum/\d+/ext\.tool$})) { # ------------------------------------- This is serious stuff, get symb and log my $symb; if ($query) {