harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r824652 - /harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Date Tue, 13 Oct 2009 09:33:32 GMT
Author: regisxu
Date: Tue Oct 13 09:33:31 2009
New Revision: 824652

URL: http://svn.apache.org/viewvc?rev=824652&view=rev
Log:
revert r824625 which is incorrect and apply new fix of countdown "selected" if selected keys
are canncelled.

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=824652&r1=824651&r2=824652&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Tue Oct 13 09:33:31 2009
@@ -494,12 +494,23 @@
 
                     Arrays.fill(flags, 0);
 
-                    doCancel();
-
-                    if (selected != 0) {
-                        return selectedKeys.size();
+                    Set<SelectionKey> cancelledKeys = cancelledKeys();
+                    synchronized (cancelledKeys) {
+                        if (cancelledKeys.size() > 0) {
+                            for (SelectionKey currentkey : cancelledKeys) {
+                                delKey(currentkey);
+                                mutableKeys.remove(currentkey);
+                                deregister((AbstractSelectionKey) currentkey);
+                                if (mutableSelectedKeys.remove(currentkey)) {
+                                    selected--;
+                                }
+                            }
+                            cancelledKeys.clear();
+                        }
+                        limitCapacity();
                     }
-                    return 0;
+
+                    return selected;
                 }
             }
         }



Mime
View raw message