harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r1002642 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/luni/src/main/native/luni/unix/ classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ classlib/modules/nio/src/te...
Date Wed, 29 Sep 2010 14:14:55 GMT
Author: hindessm
Date: Wed Sep 29 14:14:55 2010
New Revision: 1002642

URL: http://svn.apache.org/viewvc?rev=1002642&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@1002476:

  r1002476 | littlee | 2010-09-29 06:26:48 +0100 (Wed, 29 Sep 2010) | 8 lines
  
  Applying patch from HARMONY-6638:
  1. In Linux, ServerSocketChannel should be acceptable if its server socket bind any address.
  2. In Linux, SocketChannel should be connectable if it does not connect anything.
  3. The Selector should also return if an error occurred.
  4. If user change the interested operations of a selector, this
  selector should treated as a new one (but with the same
  SelectionKey). On the other hand, if the selector was return once and
  no interested operation changed, it should not  be selected next time.


Added:
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/
      - copied from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
      - copied unchanged from r1002476, harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/unix/org/apache/harmony/nio/tests/java/nio/channels/UnixSelectorTest.java
Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 14:14:55 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189
+/harmony/enhanced/java/trunk:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 14:14:55 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189
+/harmony/enhanced/java/trunk/classlib:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/classlib:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 14:14:55 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
 /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394

Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=1002642&r1=1002641&r2=1002642&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Wed Sep 29 14:14:55 2010
@@ -346,14 +346,14 @@ Java_org_apache_harmony_luni_platform_OS
 	  /* output result to int array */
 	  flagArray = (*env)->GetIntArrayElements(env, outFlags, &isCopy);
 	  for (val=0; val<countReadC; val++) {
-          if (my_pollfds[val].revents & (POLLIN | POLLPRI)) {
+          if (my_pollfds[val].revents & (POLLIN | POLLPRI | POLLHUP | POLLERR)) {
               flagArray[val] = SOCKET_OP_READ;
               changed=1;
           }
       }
 
 	  for (val=0; val<countWriteC; val++) {
-          if (my_pollfds[val+countReadC].revents & POLLOUT) {
+            if (my_pollfds[val+countReadC].revents & (POLLOUT | POLLHUP | POLLERR)) {
               flagArray[val+countReadC] = SOCKET_OP_WRITE;
               changed=1;
           }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java?rev=1002642&r1=1002641&r2=1002642&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectionKeyImpl.java
Wed Sep 29 14:14:55 2010
@@ -39,12 +39,15 @@ final class SelectionKeyImpl extends Abs
 
     private int index;
 
+    private boolean stateChange = false;
+
     public SelectionKeyImpl(AbstractSelectableChannel channel, int operations,
             Object attachment, SelectorImpl selector) {
         this.channel = channel;
         interestOps = operations;
         this.selector = selector;
         attach(attachment);
+        this.stateChange = true;
     }
 
     @Override
@@ -73,6 +76,9 @@ final class SelectionKeyImpl extends Abs
             throw new IllegalArgumentException();
         }
         synchronized (selector.keysLock) {
+            if (interestOps != operations) {
+                stateChange = true;
+            }
             interestOps = operations;
             selector.modKey(this);
         }
@@ -105,6 +111,14 @@ final class SelectionKeyImpl extends Abs
         this.index = index;
     }
 
+    boolean getStateChange() {
+        return stateChange;
+    }
+
+    void setStateChange(boolean flag) {
+        this.stateChange = flag;
+    }
+
     private void checkValid() {
         if (!isValid()) {
             throw new CancelledKeyException();

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java?rev=1002642&r1=1002641&r2=1002642&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SelectorImpl.java
Wed Sep 29 14:14:55 2010
@@ -563,20 +563,20 @@ final class SelectorImpl extends Abstrac
                     if (key.isConnected()) {
                         selectedOp = OP_WRITE & ops;
                     } else {
-                        selectedOp = OP_CONNECT & ops;
+                        selectedOp = (OP_CONNECT | OP_WRITE) & ops;
                     }
                     break;
             }
 
+            key.setReadyOps(selectedOp);
             if (0 != selectedOp) {
                 boolean wasSelected = mutableSelectedKeys.contains(key);
-                if (wasSelected && key.readyOps() != selectedOp) {
-                    key.setReadyOps(key.readyOps() | selectedOp);
-                    selected++;
-                } else if (!wasSelected) {
-                    key.setReadyOps(selectedOp);
+                if (!wasSelected) {
                     mutableSelectedKeys.add(key);
+                }
+                if (key.getStateChange()) {
                     selected++;
+                    key.setStateChange(false);
                 }
             }
         }

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java?rev=1002642&r1=1002641&r2=1002642&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Wed Sep 29 14:14:55 2010
@@ -19,21 +19,18 @@ package org.apache.harmony.nio.tests.jav
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.Pipe;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
-import java.nio.channels.Pipe;
 import java.nio.channels.spi.SelectorProvider;
 import java.util.Set;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
 
 import junit.framework.TestCase;
 import tests.support.Support_PortManager;
@@ -406,6 +403,52 @@ public class SelectorTest extends TestCa
         assertNull(failure.get());
     }
 
+    public void testOpChange() throws Exception {
+        SocketChannel sc = SocketChannel.open();
+        sc.configureBlocking(false);
+        sc.register(selector, SelectionKey.OP_CONNECT);
+        try {
+            sc.connect(LOCAL_ADDRESS);
+            int count = blockingSelect(SelectType.TIMEOUT, 100);
+            assertEquals(1, count);
+            Set<SelectionKey> selectedKeys = selector.selectedKeys();
+            assertEquals(1, selectedKeys.size());
+            SelectionKey key = selectedKeys.iterator().next();
+            assertEquals(sc.keyFor(selector), key);
+            assertEquals(SelectionKey.OP_CONNECT, key.readyOps());
+            // select again, it should return 0
+            count = selectOnce(SelectType.TIMEOUT, 100);
+            assertEquals(0, count);
+            // but selectedKeys remains the same as previous
+            assertSame(selectedKeys, selector.selectedKeys());
+            sc.finishConnect();
+
+            // same selector, but op is changed
+            SelectionKey key1 = sc.register(selector, SelectionKey.OP_WRITE);
+            assertEquals(key, key1);
+            count = blockingSelect(SelectType.TIMEOUT, 100);
+            assertEquals(1, count);
+            selectedKeys = selector.selectedKeys();
+            assertEquals(1, selectedKeys.size());
+            key = selectedKeys.iterator().next();
+            assertEquals(key, key1);
+            assertEquals(SelectionKey.OP_WRITE, key.readyOps());
+
+            selectedKeys.clear();
+        } finally {
+            try {
+                ssc.accept().close();
+            } catch (Exception e) {
+                // do nothing
+            }
+            try {
+                sc.close();
+            } catch (IOException e) {
+                // do nothing
+            }
+        }
+    }
+
     private void assert_select_SelectorClosed(SelectType type, int timeout)
             throws IOException {
         // selector is closed

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 14:14:55 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189
+/harmony/enhanced/java/trunk/drlvm:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 14:14:55 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189
+/harmony/enhanced/java/trunk/jdktools:929253-997624,997759,997980,997986,998010,998030,998619,998628,998759,998804,998822,999260,999286,999306,999591,999601,999623,999715-999716,999724,999793,1000005,1000169,1000213,1000229,1000231,1000233,1000240,1000245,1000248,1000265,1000527,1000689,1000696,1000699-1000700,1000705,1000708,1001065,1001080,1001153,1001187,1001490,1001609,1001638,1001652,1001723,1001741,1001744-1001745,1001751,1002080,1002189,1002476
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message