harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r602572 - /harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Date Sat, 08 Dec 2007 22:50:00 GMT
Author: tellison
Date: Sat Dec  8 14:50:00 2007
New Revision: 602572

URL: http://svn.apache.org/viewvc?rev=602572&view=rev
Log:
Acquire datastructure locks before modifying the selection key.
In connection with HARMONY-5219 ([classlib][nio] Jetty@Harmony corrupts big static files while
downloading)

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=602572&r1=602571&r2=602572&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
Sat Dec  8 14:50:00 2007
@@ -359,8 +359,14 @@
      */
     void modKey(SelectionKey sk) {
         // TODO: update indexes rather than recreate the key
-        delKey(sk);
-        addKey(sk);
+        synchronized (this) {
+            synchronized (keysSet) {
+                synchronized (selectedKeys) {
+                    delKey(sk);
+                    addKey(sk);
+                }
+            }
+        }
     }
 
     /**
@@ -578,6 +584,9 @@
         return unaddableSelectedKeys;
     }
 
+    /*
+     * Assumes calling thread holds locks on 'this', 'keysSet', and 'selectedKeys'. 
+     */
     private void doCancel() {
         Set<SelectionKey> cancelledKeys = cancelledKeys();
         synchronized (cancelledKeys) {



Mime
View raw message