directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r164318 - in /directory/network/trunk/src: java/org/apache/mina/io/datagram/DatagramConnector.java java/org/apache/mina/io/socket/SocketAcceptor.java java/org/apache/mina/io/socket/SocketConnector.java test/org/apache/mina/examples/echoserver/ConnectorTest.java
Date Sat, 23 Apr 2005 02:59:05 GMT
Author: trustin
Date: Fri Apr 22 19:59:04 2005
New Revision: 164318

URL: http://svn.apache.org/viewcvs?rev=164318&view=rev
Log:
* Fixed: REUSE_ADDR is not set before socket is bound to local address
* I confirmed all tests pass in Linux, so I disabled some tests for Windows.

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java?rev=164318&r1=164317&r2=164318&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java Fri
Apr 22 19:59:04 2005
@@ -132,6 +132,7 @@
         boolean initialized = false;
         try
         {
+            ch.socket().setReuseAddress( true );
             if( localAddress != null )
             {
                 ch.socket().bind( localAddress );

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?rev=164318&r1=164317&r2=164318&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java Fri Apr
22 19:59:04 2005
@@ -355,11 +355,9 @@
             try
             {
                 ssc = ServerSocketChannel.open();
-
+                ssc.socket().setReuseAddress( true );
                 ssc.configureBlocking( false );
-
                 ssc.socket().bind( req.address, req.backlog );
-
                 ssc.register( selector, SelectionKey.OP_ACCEPT, req );
 
                 channels.put( req.address, ssc );

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java?rev=164318&r1=164317&r2=164318&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java Fri Apr
22 19:59:04 2005
@@ -130,6 +130,7 @@
         boolean success = false;
         try
         {
+            ch.socket().setReuseAddress( true );
             if( localAddress != null )
             {
                 ch.socket().bind( localAddress );

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=164318&r1=164317&r2=164318&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
Fri Apr 22 19:59:04 2005
@@ -107,23 +107,31 @@
         System.out.println("* Without localAddress and initializer");
         testConnector( connector, null, null );
         
-//        marker = new MarkingInitializer();
-//        System.out.println("* Without localAddress and with initializer");
-//        testConnector( connector, null, marker );
-//        Assert.assertTrue( marker.executed );
+        System.out.println("* Without localAddress and with initializer");
+        marker = new MarkingInitializer();
+        testConnector( connector, null, marker );
+        Assert.assertTrue( marker.executed );
 
-        if( !(connector instanceof SocketConnector) )
+        // Tests below fail in Windows platform.
+        if( System.getProperty("os.name").toLowerCase().indexOf( "windows" ) >= 0 )
         {
-            // FIXME This test fails in case of SocketConnector.
-            // I don't know why yet.
-            System.out.println("* With localAddress and without initializer");
-            testConnector( connector, localAddress, null );
-            
-            marker = new MarkingInitializer();
-            System.out.println("* With localAddress and initializer");
-            testConnector( connector, localAddress, marker );
-            Assert.assertTrue( marker.executed );
+            // skip further tests
+            System.out.println( "** Skipping some tests that fails in Windows platform."
);
+            return;
         }
+        
+        System.out.println("* With localAddress and without initializer");
+        testConnector( connector, localAddress, null );
+        
+        // It takes some time for local address to be cleared by OS,
+        // so let's just get a new one rather than waiting for it.
+        clientPort = AvailablePortFinder.getNextAvailable( clientPort + 1 );
+        localAddress = new InetSocketAddress( clientPort );
+
+        System.out.println("* With localAddress and initializer");
+        marker = new MarkingInitializer();
+        testConnector( connector, localAddress, marker );
+        Assert.assertTrue( marker.executed );
     }
     
     private void testConnector( IoConnector connector, SocketAddress localAddress,
@@ -168,7 +176,7 @@
         }
         
         Thread.sleep( 300 );
-        session.close();
+        session.close( true );
         
         Assert.assertEquals( 160, readBuf.position() );
         readBuf.flip();



Mime
View raw message