directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r123248 - in incubator/directory/network/trunk/mina/src/java/org/apache/mina: io/filter protocol/filter util
Date Thu, 23 Dec 2004 23:23:02 GMT
Author: trustin
Date: Thu Dec 23 15:23:01 2004
New Revision: 123248

URL: http://svn.apache.org/viewcvs?view=rev&rev=123248
Log:
Fixed: Dead followers are not removed from followers stack
Modified:
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java?view=diff&rev=123248&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r1=123247&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r2=123248
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
Thu Dec 23 15:23:01 2004
@@ -280,8 +280,9 @@
                 SessionBuffer buf = fetchBuffer();
                 giveUpLead();
 
-                if( buf == null )
+                if( buf == null ) {
                     break;
+                }
 
                 processEvents( buf );
                 follow();
@@ -446,8 +447,17 @@
                     {
                     }
                 }
+                
+                boolean timeToLead = this == leader;
+                
+                if (!timeToLead) {
+                    // time to die
+                    synchronized (followers) {
+                        followers.remove(this);
+                    }
+                }
 
-                return this == leader;
+                return timeToLead;
             }
         }
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java?view=diff&rev=123248&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java&r1=123247&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java&r2=123248
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
Thu Dec 23 15:23:01 2004
@@ -429,7 +429,16 @@
                     }
                 }
 
-                return this == leader;
+                boolean timeToLead = this == leader;
+                
+                if (!timeToLead) {
+                    // time to die
+                    synchronized (followers) {
+                        followers.remove(this);
+                    }
+                }
+
+                return timeToLead;
             }
         }
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java?view=diff&rev=123248&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java&r1=123247&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java&r2=123248
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java	Thu Dec
23 15:23:01 2004
@@ -91,6 +91,17 @@
         items[ size ] = obj;
         size++;
     }
+    
+    public void remove( Object o ) {
+        for ( int i = size - 1; i >= 0; i-- ) {
+            if (items[i] == o) {
+                System.arraycopy(items, i + 1, items, i, size - i - 1);
+                items[size - 1] = null;
+                size --;
+                break;
+            }
+        }
+    }
 
     /**
      * Returns the first element of the queue.

Mime
View raw message