[LON-CAPA-cvs] cvs: loncom(version_2_5_X) /lonnet/perl lonnet.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Sat, 29 Sep 2007 04:06:35 -0000


albertel		Sat Sep 29 00:06:35 2007 EDT

  Modified files:              (Branch: version_2_5_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - backport 1.914 
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.910.2.1 loncom/lonnet/perl/lonnet.pm:1.910.2.2
--- loncom/lonnet/perl/lonnet.pm:1.910.2.1	Mon Sep 24 20:26:20 2007
+++ loncom/lonnet/perl/lonnet.pm	Sat Sep 29 00:06:34 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.910.2.1 2007/09/25 00:26:20 albertel Exp $
+# $Id: lonnet.pm,v 1.910.2.2 2007/09/29 04:06:34 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -582,6 +582,27 @@
     }
     return ($spare_server,$lowest_load);
 }
+
+# --------------------------- ask offload servers if user already has a session
+sub find_existing_session {
+    my ($udom,$uname) = @_;
+    foreach my $try_server (@{ $spareid{'primary'} },
+			    @{ $spareid{'default'} }) {
+	return $try_server if (&has_user_session($try_server, $udom, $uname));
+    }
+    return;
+}
+
+# -------------------------------- ask if server already has a session for user
+sub has_user_session {
+    my ($lonid,$udom,$uname) = @_;
+    my $result = &reply(join(':','userhassession',
+			     map {&escape($_)} ($udom,$uname)),$lonid);
+    return 1 if ($result eq 'ok');
+
+    return 0;
+}
+
 # --------------------------------------------- Try to change a user's password
 
 sub changepass {