directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r446526 - in /directory/trunks/mina/core/src: main/java/org/apache/mina/common/support/ main/java/org/apache/mina/transport/socket/nio/ main/java/org/apache/mina/transport/vmpipe/ test/java/org/apache/mina/common/support/
Date Fri, 15 Sep 2006 05:44:12 GMT
Author: trustin
Date: Thu Sep 14 22:44:11 2006
New Revision: 446526

URL: http://svn.apache.org/viewvc?view=rev&rev=446526
Log:
* Reverted Peter's fix because we need more testing and clarification
* Fixed a possible thread safety problem in IoServiceListenerSupport
* Fixed a bug that IoServiceListener.serviceActivated() is not fired for VM-pipe transport

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoAcceptor.java
Thu Sep 14 22:44:11 2006
@@ -36,7 +36,6 @@
 {
     protected BaseIoAcceptor()
     {
-        super( false );
     }
     
     public void bind( SocketAddress address, IoHandler handler ) throws IOException

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
Thu Sep 14 22:44:11 2006
@@ -35,11 +35,6 @@
 {
     protected BaseIoConnector()
     {
-        super( true );
-    }
-
-    protected BaseIoConnector( boolean deactivateWhenIdle) {
-        super( deactivateWhenIdle );
     }
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler )

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoService.java
Thu Sep 14 22:44:11 2006
@@ -45,9 +45,9 @@
      */
     private final IoServiceListenerSupport listeners;
     
-    protected BaseIoService( boolean deactivateWhenIdle )
+    protected BaseIoService()
     {
-        this.listeners = new IoServiceListenerSupport( deactivateWhenIdle );
+        this.listeners = new IoServiceListenerSupport();
     }
     
     public IoFilterChainBuilder getFilterChainBuilder()

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/IoServiceListenerSupport.java
Thu Sep 14 22:44:11 2006
@@ -64,14 +64,11 @@
      */
     private final Map managedSessions = new HashMap();
     
-    private final boolean deactivateWhenIdle;
-    
     /**
      * Creates a new instance.
      */
-    public IoServiceListenerSupport( boolean deactivateWhenIdle )
+    public IoServiceListenerSupport()
     {
-        this.deactivateWhenIdle = deactivateWhenIdle;
     }
     
     /**
@@ -123,7 +120,7 @@
         
         synchronized( sessions )
         {
-            return Collections.unmodifiableSet( sessions );
+            return new IdentityHashSet( sessions );
         }
     }
 
@@ -248,29 +245,25 @@
         
         // Get the session set.
         Set sessions;
+        boolean lastSession = false;
         synchronized( managedSessions )
         {
             sessions = ( Set ) managedSessions.get( serviceAddress );
-        }
-        
-        // Ignore if unknown.
-        if( sessions == null )
-        {
-            return;
-        }
-        
-        // Try to remove the remaining empty seession set after removal.
-        boolean lastSession = false;
-        synchronized( sessions )
-        {
-            sessions.remove( session );
-            if( sessions.isEmpty() )
+            // Ignore if unknown.
+            if( sessions == null )
+            {
+                return;
+            }
+            
+            // Try to remove the remaining empty seession set after removal.
+            synchronized( sessions )
             {
-                synchronized( managedSessions )
+                sessions.remove( session );
+                if( sessions.isEmpty() )
                 {
                     managedSessions.remove( serviceAddress );
+                    lastSession = true;
                 }
-                lastSession = true;
             }
         }
         
@@ -291,8 +284,8 @@
         finally
         {
             // Fire a virtual service deactivation event for the last session of the connector.
-            //TODO double-check that this is *STILL* the last service. May not be the case
-            if( deactivateWhenIdle && lastSession )
+            //TODO double-check that this is *STILL* the last session. May not be the case
+            if( session.getService() instanceof IoConnector && lastSession )
             {
                 fireServiceDeactivated(
                         session.getService(), session.getServiceAddress(),

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Thu Sep 14 22:44:11 2006
@@ -73,7 +73,7 @@
      */
     public SocketConnector()
     {
-        this( 1, true );
+        this( 1 );
     }
     
     /**
@@ -81,10 +81,8 @@
      *
      * @param processorCount Number of processing threads
      */
-    public SocketConnector( int processorCount, boolean deactivateWhenIdle )
+    public SocketConnector( int processorCount )
     {
-        super( deactivateWhenIdle );
-        
         if( processorCount < 1 )
         {
             throw new IllegalArgumentException( "Must have at least one processor" );

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
Thu Sep 14 22:44:11 2006
@@ -82,6 +82,8 @@
                                           ( VmPipeAddress ) address,
                                           handler, config, getListeners() ) );
         }
+        
+        getListeners().fireServiceActivated( this, address, handler, config );
     }
     
     public void unbind( SocketAddress address )

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
Thu Sep 14 22:44:11 2006
@@ -52,11 +52,11 @@
         }
     };
 
-    public VmPipeConnector() {
-    }
-
-    public VmPipeConnector(boolean deactivateWhenIdle) {
-        super( deactivateWhenIdle );
+    /**
+     * Creates a new instance.
+     */
+    public VmPipeConnector()
+    {
     }
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig
config )

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java?view=diff&rev=446526&r1=446525&r2=446526
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
Thu Sep 14 22:44:11 2006
@@ -49,7 +49,7 @@
 
     public void testServiceLifecycle() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+        IoServiceListenerSupport support = new IoServiceListenerSupport();
     
         MockControl listenerControl = MockControl.createStrictControl( IoServiceListener.class
);
         IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
@@ -87,7 +87,7 @@
     
     public void testSessionLifecycle() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+        IoServiceListenerSupport support = new IoServiceListenerSupport();
     
         TestSession session = new TestSession( ADDRESS );
         
@@ -138,7 +138,7 @@
     
     public void testDisconnectOnUnbind() throws Exception
     {
-        final IoServiceListenerSupport support = new IoServiceListenerSupport( false );
+        final IoServiceListenerSupport support = new IoServiceListenerSupport();
     
         MockControl acceptorControl = MockControl.createStrictControl( IoAcceptor.class );
         IoAcceptor acceptor = ( IoAcceptor ) acceptorControl.getMock();
@@ -213,7 +213,7 @@
     
     public void testConnectorActivation() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport( true );
+        IoServiceListenerSupport support = new IoServiceListenerSupport();
     
         MockControl connectorControl = MockControl.createStrictControl( IoConnector.class
);
         IoConnector connector = ( IoConnector ) connectorControl.getMock();



Mime
View raw message