directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r344371 - in /directory/network/trunk/src: java/org/apache/mina/common/ java/org/apache/mina/filter/ java/org/apache/mina/filter/codec/ java/org/apache/mina/filter/support/ java/org/apache/mina/transport/socket/nio/support/ java/org/apache/...
Date Tue, 15 Nov 2005 14:54:53 GMT
Author: trustin
Date: Tue Nov 15 06:54:39 2005
New Revision: 344371

URL: http://svn.apache.org/viewcvs?rev=344371&view=rev
Log:
Resolved issue: DIRMINA-125 - IoSession.isClosing()
* Added IoSession.isClosing() and implemented it for all transport types

* Removed some old TODOs.

Modified:
    directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
    directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
    directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java
    directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java
    directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSession.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSession.java Tue Nov 15 06:54:39
2005
@@ -134,6 +134,12 @@
      * Returns <code>true</code> if this session is connected with remote peer.
      */
     boolean isConnected();
+    
+    /**
+     * Returns <code>true</tt> if and only if this session is being closed
+     * (but not disconnected yet) or is closed.
+     */
+    boolean isClosing();
 
     /**
      * Returns the socket address of remote peer. 

Modified: directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java Tue Nov 15 06:54:39
2005
@@ -66,8 +66,6 @@
  * }
  * </pre>
  * 
- * TODO: Test this filter regressively in a multi-processor machine.
- * 
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Tue Nov 15 06:54:39 2005
@@ -151,16 +151,9 @@
     
     public void sessionClosed( NextFilter nextFilter, IoSession session ) throws Exception
     {
-        try
-        {
-            nextFilter.sessionClosed( session );
-        }
-        finally
-        {
-            // Dispose encoder and decoder safely.
-            disposeEncoder( session );
-            disposeDecoder( session );
-        }
+        disposeEncoder( session );
+        disposeDecoder( session );
+        nextFilter.sessionClosed( session );
     }
 
     private ProtocolEncoder getEncoder( IoSession session )

Modified: directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java Tue Nov
15 06:54:39 2005
@@ -477,8 +477,6 @@
                 outNetBuffer.flip();
                 initialHandshakeStatus = result.getHandshakeStatus();
                 writeNetBuffer( nextFilter );
-                // return to allow data on out buffer being sent
-                // TODO: We might want to send more data immidiatley?
             }
             else
             {

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Tue Nov 15 06:54:39 2005
@@ -61,6 +61,7 @@
     private SelectionKey key;
     
     private final CloseFuture closeFuture = new CloseFuture();
+    private boolean closing;
 
     /**
      * Creates a new instance.
@@ -114,12 +115,18 @@
     
     public CloseFuture close()
     {
-        if( !closeFuture.isReady() )
+        if( !closing && !closeFuture.isReady() )
         {
+            closing = true;
             managerFilterChain.filterClose( this, closeFuture );
         }
         return closeFuture;
     }
+    
+    public boolean isClosing()
+    {
+        return closing;
+    }
 
     Queue getWriteRequestQueue()
     {
@@ -129,7 +136,14 @@
     public WriteFuture write( Object message )
     {
         WriteFuture future = new WriteFuture();
-        filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        if( isClosing() )
+        {
+            future.setWritten( false );
+        }
+        else
+        {
+            filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        }
         return future;
     }
     

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
Tue Nov 15 06:54:39 2005
@@ -56,6 +56,7 @@
     private final SocketAddress localAddress;
     private SelectionKey key;
     private CloseFuture closeFuture = new CloseFuture();
+    private boolean closing;
     private int readBufferSize = DEFAULT_READ_BUFFER_SIZE;
 
     /**
@@ -118,13 +119,19 @@
     
     public CloseFuture close()
     {
-        if( !closeFuture.isReady() )
+        if( !closing && !closeFuture.isReady() )
         {
+            closing = true;
             filterChain.filterClose( this, closeFuture );
         }
 
         return closeFuture;
     }
+    
+    public boolean isClosing()
+    {
+        return closing;
+    }
 
     Queue getWriteRequestQueue()
     {
@@ -142,7 +149,14 @@
     public WriteFuture write( Object message )
     {
         WriteFuture future = new WriteFuture();
-        filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        if( isClosing() )
+        {
+            future.setWritten( false );
+        }
+        else
+        {
+            filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        }
         return future;
     }
 

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
Tue Nov 15 06:54:39 2005
@@ -42,7 +42,8 @@
 
     final Object lock;
 
-    boolean closed;
+    private boolean closing;
+    CloseFuture closeFuture = new CloseFuture();
 
     /**
      * Constructor for client-side session.
@@ -129,15 +130,32 @@
 
     public CloseFuture close()
     {
-        CloseFuture future = new CloseFuture();
-        managerFilterChain.filterClose( this, future );
-        return future;
+        if( !closing )
+        {
+            closing = true;
+            managerFilterChain.filterClose( this, closeFuture );
+        }
+            
+        return closeFuture;
+    }
+    
+    public boolean isClosing()
+    {
+        return closing;
     }
+    
 
     public WriteFuture write( Object message )
     {
         WriteFuture future = new WriteFuture();
-        this.filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        if( isClosing() )
+        {
+            future.setWritten( false );
+        }
+        else
+        {
+            this.filterChain.filterWrite( this, new WriteRequest( message, future ) );
+        }
         return future;
     }
 
@@ -153,7 +171,7 @@
 
     public boolean isConnected()
     {
-        return !closed;
+        return !closeFuture.isClosed();
     }
 
     public SocketAddress getRemoteAddress()

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
Tue Nov 15 06:54:39 2005
@@ -18,14 +18,14 @@
         VmPipeSessionImpl s = ( VmPipeSessionImpl ) session;
         synchronized( s.lock )
         {
-            if( s.closed )
+            if( s.isConnected() )
             {
-                writeRequest.getFuture().setWritten( false );
+                s.remoteSession.getManagerFilterChain().messageReceived( s.remoteSession,
writeRequest.getMessage() );
+                writeRequest.getFuture().setWritten( true );
             }
             else 
             {
-                s.remoteSession.getManagerFilterChain().messageReceived( s.remoteSession,
writeRequest.getMessage() );
-                writeRequest.getFuture().setWritten( true );
+                writeRequest.getFuture().setWritten( false );
             }
         }
     }
@@ -35,9 +35,9 @@
         VmPipeSessionImpl s = ( VmPipeSessionImpl ) session;
         synchronized( s.lock )
         {
-            if( !s.closed )
+            if( !s.closeFuture.isClosed() )
             {
-                s.closed = s.remoteSession.closed = true;
+                s.remoteSession.closeFuture.setClosed( true );
                 s.getManagerFilterChain().sessionClosed( session );
                 s.remoteSession.getManagerFilterChain().sessionClosed( s.remoteSession );
             }

Modified: directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java Tue Nov 15 06:54:39
2005
@@ -121,6 +121,11 @@
             protected void updateTrafficMask()
             {
             }
+
+            public boolean isClosing()
+            {
+                return false;
+            }
         };
         
         future.setSession( session );

Modified: directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java Tue Nov
15 06:54:39 2005
@@ -200,6 +200,11 @@
         protected void updateTrafficMask()
         {
         }
+
+        public boolean isClosing()
+        {
+            return false;
+        }
     }
 
     private class EventOrderTestFilter implements IoFilter

Modified: directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
Tue Nov 15 06:54:39 2005
@@ -189,6 +189,11 @@
         protected void updateTrafficMask()
         {
         }
+
+        public boolean isClosing()
+        {
+            return false;
+        }
     }
     
     private static class EventOrderChecker implements NextFilter
@@ -292,6 +297,11 @@
         public int getScheduledWriteRequests()
         {
             return 0;
+        }
+
+        public boolean isClosing()
+        {
+            return false;
         }
     }
     

Modified: directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?rev=344371&r1=344370&r2=344371&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
Tue Nov 15 06:54:39 2005
@@ -230,5 +230,10 @@
         protected void updateTrafficMask()
         {
         }
+
+        public boolean isClosing()
+        {
+            return false;
+        }
     }
 }



Mime
View raw message