[LON-CAPA-cvs] cvs: loncom / lond

foxr lon-capa-cvs@mail.lon-capa.org
Thu, 29 Apr 2004 10:24:40 -0000


foxr		Thu Apr 29 06:24:40 2004 EDT

  Modified files:              
    /loncom	lond 
  Log:
  BUG 1381 - Fix unsub not working:
             o Logic in sub unsub was not correct.
             o Call to unsub from the unsub handler in the main code had
               an extra leading parameter (socket to the client).
  
  
  
  
Index: loncom/lond
diff -u loncom/lond:1.187 loncom/lond:1.188
--- loncom/lond:1.187	Thu Apr 29 03:18:10 2004
+++ loncom/lond	Thu Apr 29 06:24:40 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.187 2004/04/29 07:18:10 albertel Exp $
+# $Id: lond,v 1.188 2004/04/29 10:24:40 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,7 +53,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.187 $'; #' stupid emacs
+my $VERSION='$Revision: 1.188 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -1928,7 +1928,7 @@
 		    if(isClient) {
 			my ($cmd,$fname)=split(/:/,$userinput);
 			if (-e $fname) {
-			    print $client &unsub($client,$fname,$clientip);
+			    print $client &unsub($fname,$clientip);
 			} else {
 			    print $client "not_found\n";
 			}
@@ -3040,17 +3040,36 @@
 sub unsub {
     my ($fname,$clientip)=@_;
     my $result;
+    my $unsubs = 0;		# Number of successful unsubscribes:
+
+
+    # An old way subscriptions were handled was to have a 
+    # subscription marker file:
+
+    Debug("Attempting unlink of $fname.$clientname");
     if (unlink("$fname.$clientname")) {
-	$result="ok\n";
-    } else {
-	$result="not_subscribed\n";
-    }
+	$unsubs++;		# Successful unsub via marker file.
+    } 
+
+    # The more modern way to do it is to have a subscription list
+    # file:
+
     if (-e "$fname.subscription") {
 	my $found=&addline($fname,$clientname,$clientip,'');
-	if ($found) { $result="ok\n"; }
+	if ($found) { 
+	    $unsubs++;
+	}
+    } 
+
+    #  If either or both of these mechanisms succeeded in unsubscribing a 
+    #  resource we can return ok:
+
+    if($unsubs) {
+	$result = "ok\n";
     } else {
-	if ($result != "ok\n") { $result="not_subscribed\n"; }
+	$result = "not_subscribed\n";
     }
+
     return $result;
 }