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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 02 May 2007 22:00:03 -0000


albertel		Wed May  2 18:00:03 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - &escaping of the id makes it expand so we could cross the magic 250 characters mark after escaping the id, so check the length of the id after escaping it it might exceed things
  - also start complainging if caching is failing.
  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.871 loncom/lonnet/perl/lonnet.pm:1.872
--- loncom/lonnet/perl/lonnet.pm:1.871	Fri Apr 20 17:48:09 2007
+++ loncom/lonnet/perl/lonnet.pm	Wed May  2 18:00:02 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.871 2007/04/20 21:48:09 albertel Exp $
+# $Id: lonnet.pm,v 1.872 2007/05/02 22:00:02 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1065,7 +1065,10 @@
 my $hits=0;
 sub make_key {
     my ($name,$id) = @_;
-    if (length($id) > 200) { $id=length($id).':'.&Digest::MD5::md5_hex($id); }
+    if (length($id) > 65 
+	&& length(&escape($id)) > 200) {
+	$id=length($id).':'.&Digest::MD5::md5_hex($id);
+    }
     return &escape($name.':'.$id);
 }
 
@@ -1112,7 +1115,9 @@
 	$time=600;
     }
     if ($debug) { &Apache::lonnet::logthis("Setting $id to $value"); }
-    $memcache->set($id,$setvalue,$time);
+    if (!($memcache->set($id,$setvalue,$time))) {
+	&logthis("caching of id -> $id  failed");
+    }
     # need to make a copy of $value
     #&make_room($id,$value,$debug);
     return $value;