directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r158878 - in directory/network/trunk/src/java/org/apache/mina: io/datagram/DatagramAcceptor.java io/datagram/DatagramConnector.java io/socket/SocketAcceptor.java io/socket/SocketConnector.java io/socket/SocketIoProcessor.java registry/SimpleServiceRegistry.java
Date Thu, 24 Mar 2005 04:37:38 GMT
Author: trustin
Date: Wed Mar 23 20:37:36 2005
New Revision: 158878

URL: http://svn.apache.org/viewcvs?view=rev&rev=158878
Log:
Fixed: Deadlock on bind() (I hope so :)
Fixed: SimpleServiceRegistry.unbind() doesn't unbind all.

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    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/java/org/apache/mina/io/socket/SocketIoProcessor.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=158877&r2=158878
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java Wed
Mar 23 20:37:36 2005
@@ -91,12 +91,14 @@
             throw new IllegalArgumentException( "Unsupported port number: 0" );
 
         RegistrationRequest request = new RegistrationRequest( address, handler );
-        synchronized( registerQueue )
+        synchronized( this )
         {
-            registerQueue.push( request );
+            synchronized( registerQueue )
+            {
+                registerQueue.push( request );
+            }
+            startupWorker();
         }
-
-        startupWorker();
         selector.wakeup();
         
         synchronized( request )
@@ -126,12 +128,14 @@
             throw new NullPointerException( "address" );
 
         CancellationRequest request = new CancellationRequest( address );
-        synchronized( cancelQueue )
+        synchronized( this )
         {
-            cancelQueue.push( request );
+            synchronized( cancelQueue )
+            {
+                cancelQueue.push( request );
+            }
+            startupWorker();
         }
-
-        startupWorker();
         selector.wakeup();
         
         synchronized( request )
@@ -211,7 +215,9 @@
                     {
                         synchronized( DatagramAcceptor.this )
                         {
-                            if( selector.keys().isEmpty() )
+                            if( selector.keys().isEmpty() &&
+                                registerQueue.isEmpty() &&
+                                cancelQueue.isEmpty() )
                             {
                                 worker = null;
                                 break;

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?view=diff&r1=158877&r2=158878
==============================================================================
--- 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 Wed
Mar 23 20:37:36 2005
@@ -98,7 +98,6 @@
             {
                 registerQueue.push( request );
             }
-
             startupWorker();
         }
 
@@ -145,6 +144,7 @@
             {
                 cancelQueue.push( key );
             }
+            startupWorker();
         }
 
         selector.wakeup();
@@ -193,7 +193,9 @@
                     {
                         synchronized( DatagramConnector.this )
                         {
-                            if( selector.keys().isEmpty() )
+                            if( selector.keys().isEmpty() &&
+                                registerQueue.isEmpty() &&
+                                cancelQueue.isEmpty() )
                             {
                                 worker = null;
                                 break;

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?view=diff&r1=158877&r2=158878
==============================================================================
--- 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 Wed Mar
23 20:37:36 2005
@@ -116,12 +116,15 @@
 
         RegistrationRequest request = new RegistrationRequest( address, backlog, handler
);
 
-        synchronized( registerQueue )
+        synchronized( this )
         {
-            registerQueue.push( request );
+            synchronized( registerQueue )
+            {
+                registerQueue.push( request );
+            }
+            startupWorker();
         }
-
-        startupWorker();
+        
         selector.wakeup();
         
         synchronized( request )
@@ -166,13 +169,15 @@
         }
 
         CancellationRequest request = new CancellationRequest( address );
-
-        synchronized( cancelQueue )
+        synchronized( this )
         {
-            cancelQueue.push( request );
+            synchronized( cancelQueue )
+            {
+                cancelQueue.push( request );
+            }
+            startupWorker();
         }
-
-        startupWorker();
+        
         selector.wakeup();
 
         synchronized( request )
@@ -225,7 +230,9 @@
                     {
                         synchronized( SocketAcceptor.this )
                         {
-                            if( selector.keys().isEmpty() )
+                            if( selector.keys().isEmpty() &&
+                                registerQueue.isEmpty() &&
+                                cancelQueue.isEmpty() )
                             {
                                 worker = null;
 

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?view=diff&r1=158877&r2=158878
==============================================================================
--- 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 Wed Mar
23 20:37:36 2005
@@ -101,12 +101,14 @@
         else
         {
             ConnectionRequest request = new ConnectionRequest( ch, timeout, handler );
-            synchronized( connectQueue )
+            synchronized( this )
             {
-                connectQueue.push( request );
+                synchronized( connectQueue )
+                {
+                    connectQueue.push( request );
+                }
+                startupWorker();
             }
-
-            startupWorker();
             selector.wakeup();
 
             synchronized( request )
@@ -280,7 +282,8 @@
                     {
                         synchronized( SocketConnector.this )
                         {
-                            if( selector.keys().isEmpty() )
+                            if( selector.keys().isEmpty() &&
+                                connectQueue.isEmpty() )
                             {
                                 worker = null;
                                 break;

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java?view=diff&r1=158877&r2=158878
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java Wed
Mar 23 20:37:36 2005
@@ -93,7 +93,6 @@
             {
                 newSessions.push( session );
             }
-
             startupWorker();
         }
 
@@ -499,7 +498,8 @@
                     {
                         synchronized( SocketIoProcessor.this )
                         {
-                            if( selector.keys().isEmpty() )
+                            if( selector.keys().isEmpty() &&
+                                newSessions.isEmpty() )
                             {
                                 worker = null;
                                 break;

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?view=diff&r1=158877&r2=158878
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Wed
Mar 23 20:37:36 2005
@@ -96,8 +96,24 @@
     {
         ProtocolAcceptor acceptor = findProtocolAcceptor( service
                 .getTransportType() );
-        acceptor.unbind( new InetSocketAddress( service.getPort() ) );
-        acceptor.unbind( new VmPipeAddress( service.getPort() ) );
+        try
+        {
+            acceptor.unbind( new InetSocketAddress( service.getPort() ) );
+        }
+        catch( Exception e )
+        {
+            // ignore
+        }
+        
+        try
+        {
+            acceptor.unbind( new VmPipeAddress( service.getPort() ) );
+        }
+        catch( Exception e )
+        {
+            // ignore
+        }
+
         services.remove( service );
         stopThreadPools();
     }



Mime
View raw message