[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /auth lonacc.pm

raeburn raeburn at source.lon-capa.org
Wed Jul 31 22:51:46 EDT 2019


raeburn		Thu Aug  1 02:51:46 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/auth	lonacc.pm 
  Log:
  - For 2.11
    Backport 1.171 
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.159.2.7 loncom/auth/lonacc.pm:1.159.2.8
--- loncom/auth/lonacc.pm:1.159.2.7	Wed Jul 31 17:42:29 2019
+++ loncom/auth/lonacc.pm	Thu Aug  1 02:51:45 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.159.2.7 2019/07/31 17:42:29 raeburn Exp $
+# $Id: lonacc.pm,v 1.159.2.8 2019/08/01 02:51:45 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -332,17 +332,21 @@
             ($is_balancer,$otherserver) =
                 &Apache::lonnet::check_loadbalancing($user,$domain,'login');
             if ($is_balancer) {
-                if ($otherserver eq '') {
+                # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
+                my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
+                if (($found_server) && ($balancer_cookie =~ /^\Q$domain\E_\Q$user\E_/)) {
+                    $otherserver = $found_server;
+                } elsif ($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$/, at hosts)) {
-                        $hosthere = $otherserver;
+                    if ($otherserver ne '') {
+                        my @hosts = &Apache::lonnet::current_machine_ids();
+                        if (grep(/^\Q$otherserver\E$/, at hosts)) {
+                            $hosthere = $otherserver;
+                        }
                     }
                 }
             }
@@ -552,7 +556,7 @@
         my $checkexempt;
         if ($env{'user.loadbalexempt'} eq $r->dir_config('lonHostID')) {
             if ($env{'user.loadbalcheck.time'} + 600 > time) {
-                $checkexempt = 1;    
+                $checkexempt = 1;
             }
         }
         if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) {
@@ -562,12 +566,23 @@
             ($is_balancer,$otherserver) =
                 &Apache::lonnet::check_loadbalancing($env{'user.name'},
                                                      $env{'user.domain'});
+            if ($is_balancer) {
+                unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {
+                    # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
+                    my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
+                    if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
+                        $otherserver = $found_server;
+                    }
+                }
+            }
         }
         if ($is_balancer) {
-            $r->set_handlers('PerlResponseHandler'=>
-                             [\&Apache::switchserver::handler]);
-            if ($otherserver ne '') {
-                $env{'form.otherserver'} = $otherserver;
+            unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {
+                $r->set_handlers('PerlResponseHandler'=>
+                                 [\&Apache::switchserver::handler]);
+                if ($otherserver ne '') {
+                    $env{'form.otherserver'} = $otherserver;
+                }
             }
             unless (($env{'form.origurl'}) || ($r->uri eq '/adm/roles') ||
                     ($r->uri eq '/adm/switchserver') || ($r->uri eq '/adm/sso')) {




More information about the LON-CAPA-cvs mailing list